Simple C++ solution


  • 0
    S

    class Solution {
    public:
    int hIndex(vector<int>& citations) {

        sort (citations.begin(), citations.end());
        int hin = 0;
        for(int i=citations.size()-1; i>=0; i--)
        {
            if(citations.at(i) > hin)
            {
                hin += 1;
            }
            else
                break;
        }
        
        return hin;
    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.