题目链接:点击这里
AC代码:
class Solution {
public:
int hIndex(vector<int>& citations) {
int n = citations.size();
if(n == 0) return 0;
sort(citations.begin(), citations.end());
int ans = 0;
for(int i = 0; i < n; i++)
{
int h = n - i;
if(citations[i] >= h)
{
ans = h;
break;
}
}
return ans;
}
};