```
public class Solution {
public int hIndex(int[] citations) {
int res, len;
res = len = citations.length;
int[] count = new int[len + 1];
for(int i : citations){
if(i < res){
if(count[res] == 0){
res--;
}
else{
count[res]--;
}
count[i]++;
}
}
return res;
}
}
```

First set h-index to array.length, if we encounter a number less than current h, h should subtract by one. But, if we previously used higher standards and ruled out a number that shouldn't have been under current h, we don't do h--.