```
class Solution {
public:
int hIndex(vector<int>& citations)
{
int len=citations.size();
if (len==0) return 0;
int left=0,right=len;
while (left<right)
{
int mid=(right-left)/2+left;
if (citations[mid]>=len-mid) right=mid;
else left=mid+1;
}
return len-right;
}
};
```