leetcode274
我的方法:遍历
class Solution {
public:
int hIndex(vector<int>& citations) {
sort(citations.begin(),citations.end());
int n=citations.size();
int h=0;
for(int i=0;i<n;i++){
if(citations[i]>=n-i){
h = max(h,n-i);
}
}
return h;
}
};
时间复杂度:O(nlogn)
performance:Beats 100.00% of users with C++