您的位置:首页 > 其它

LeetCode *** 275. H-Index II

2016-04-16 15:35 369 查看
题目:

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(vector<int>& citations) {

int h=0;

for(int i=citations.size()-1;i>=0;--i){
if(h>=citations[i])return h;
h++;
}

return h;
}
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: