sort the vector, then go through vector and reduce the possible h-index by 1 if element is less than it until the first element which is larger than it occurs.

```
int hIndex(vector<int>& citations) {
std::sort(citations.begin(), citations.end());
int result = citations.size();
for(int i = 0; i < citations.size(); i++)
{
if (citations[i] < result)
result--;
else
break;
}
return result;
}
```