Leetcode 274 Solution

This article provides solution to leetcode question 274 (h-index)

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;
    }
};