```
public int hIndex(int[] citations) {
int n = citations.length, h = n, sum;
int[] cnt = new int[n + 1];
for (int c : citations) cnt[Math.min(n, c)]++;
for (h = n, sum = cnt[n]; sum < h; sum += cnt[--h]);
return h;
}
```