Simple 5-line C++ Solution


  • 0
    G
        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;
        }
    

Log in to reply
 

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