Untitled

 avatar
unknown
plain_text
a year ago
286 B
3
Indexable
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;
    }
};
Editor is loading...
Leave a Comment