Simple C++ Solution


  • 0
    S
    class Solution {
    public:
        int hIndex(vector<int>& citations) {
            sort(citations.begin(), citations.end());
            int h_idx = 0;
            for (int i=0;i<citations.size();i++) {
                if (citations[i]>h_idx && citations[i-h_idx]>h_idx) h_idx++;
            }
            return h_idx;
        }
    };
    

Log in to reply
 

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