274. H 指数
排序后就很解决
cpp
class Solution {
public:
int hIndex(vector<int>& citations) {
int n = citations.size();
sort(citations.begin(),citations.end());
int ans = 0;
for(int i=n-1;i>=0;--i){
int h = n- i;
if(citations[i] >= h){
ans = h;
}else{
break;
}
}
return ans;
}
};