```
class Solution {
public:
int hIndex(vector<int>& c) {
int len = c.size();
if(len==0) return 0;
sort(c.begin(), c.end(), [](int a, int b){return a>b;});
int res=-1;
for(int i=0; i<len; ++i)
{
res = max(res, min(i+1, c[i]));
}
return res;
}
};
```