```
public class Solution {
public int hIndex(int[] citations) {
int[] sum = new int[citations.length + 2];
for(int c : citations){
int index = c >= citations.length ? citations.length : c;
sum[index]++;
}
for(int i = sum.length - 2; i >= 0; i--){
sum[i] += sum[i + 1];
if(sum[i] >= i)
return i;
}
return 0;
}
```

}