leetcode274. H 指数

自己写的先排序后反向遍历
class Solution {
public int hIndex(int[] citations) {
int n = citations.length;
Arrays.sort(citations);
if(citations[0] >= n) return n;
if(citations[n-1] == 0) return 0;
int h = 0;
for(int i = n - 1;i >= 0;--i){
if(citations[i] > h) ++h;
}
return h;
}
}
浙公网安备 33010602011771号