题目描述
示例:
题目分析
- h指数小于等于数组元素个数
- 数组是有序的
- 求h指数也就是求[i, citations.length]中citations[i] > h的边界
思路:
代码实现:
class Solution {
public int hIndex(int[] citations) {
int len = citations.length;
int h = 0;
for (int i = len - 1; i >= 0; i--) {
if (citations[i] > h) {
h++;
} else {
break;
}
}
return h;
}
}