Posted on

Description

Submisison

class Solution {
public:
    int hIndex(vector<int>& citations) {
        int n = citations.size();
        int lower = 0, upper = n;

        while(lower < upper) {
            int mid = lower + (upper - lower) / 2;

            if(n -1 >= mid && citations[n - 1 - mid] > mid) {
                lower = mid + 1;
            } else {
                upper = mid;
            }
        }

        return lower;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *