Follow up for H-Index: What if the citations
array is sorted in ascending order? Could you optimize your algorithm?
程序如下所示:
class Solution {
public int hIndex(int[] citations) {
int count = 0;
for (int i = citations.length - 1; i >= 0; -- i){
if (citations[i] >= citations.length - i){
count = citations.length - i;
}
}
return count;
}
}