```
int hIndex(vector<int>& citations) {
int n = citations.size();
int l = 0;
int r = n;
while(l < r){
int mid = (r - l) / 2 + l;
if(citations[mid] < n - mid) l = mid + 1;
else r = mid;
}
return n - r;
```