Leetcode 274 Solution
This article provides solution to leetcode question 274 (h-index)
Access this page by simply typing in "lcs 274" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/h-index
Solution
class Solution {
public:
int hIndex(vector<int>& citations) {
sort(citations.begin(), citations.end());
for (int i = 0; i < citations.size(); i++)
if (citations[i] >= citations.size() - i)
return citations.size() - i;
return 0;
}
};