题目描述:
示例:
题目分析:
- h指数是论文数量,所以h小于等于论文总数,也就是小于等于citations.length;
- 对数组citations = [3,0,6,1,5]排序得到citations = [0,1,3,5,6],它的h指数是3,也就是[len - h, len]中,citations[len -3] >= 3;
思路:
代码实现:
class Solution {
public int hIndex(int[] citations) {
int h = 0;
int len = citations.length;
Arrays.sort(citations);
for (int i = len - 1; i >= 0; i--) {
if (citations[i] > h) {
h++;
}
}
return h;
}
}