[leetcode_275]H-Index II

This solution passes, but it does not use an O(log n) approach. Marking this for a revisit next time.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class Solution {
public:
    int hIndex(vector<int>& citations) {
        //sort(citations.begin(), citations.end(), greater<int>());
        int size = citations.size();
        int max = 0;
        for (int i = size - 1; i >= 0; i--) {
            int j = size - 1 - i;
            if (citations[i] >= j + 1) {
                max = j + 1;
            }
        }
        return max;
    }
};