```
public class Solution {
public int hIndex(int[] citations) {
if (citations.length == 0) {
return 0;
}
int begin = 0;
int end = citations.length - 1;
while (begin < end) {
int mid = (begin + end) / 2;
if (citations[mid] < citations.length - mid) {
begin = mid + 1;
} else {
end = mid;
}
}
return citations[begin] < citations.length - begin ? 0 : citations.length - begin;
}
```

}