Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
286 B
0
Indexable
Never
class Solution {
public:
    int hIndex(vector<int>& cit) {
        int n=cit.size();
        int s=0,e=n-1;
        while(s<=e){
            int mid=s+(e-s)/2;
            int h=n-mid;
            if(cit[mid]<h) s=mid+1;
            else e=mid-1;
        }
        return n-s;
    }
};
Leave a Comment