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

}