```
public class Solution {
public int hIndex(int[] citations) {
int left = 0;
int L = citations.length;
int right = L-1;
while(left <= right) {
int mid = left + (right-left)/2;
if(citations[mid] < L-mid)
left = mid+1;
else if(citations[mid] > L-mid)
right = mid-1;
else
return citations[mid];
}
return L-left;
}
}
```