My 4ms cpp solution, beat 100% cpp submissions.


  • 0
    L

    class Solution {
    public:
    int hIndex(vector<int>& citations) {
    sort(citations.begin(), citations.end());
    int i = 0;
    int n = citations.size();
    while (i<=n-1&&citations[n-1-i]>=i+1) {
    i++;
    }
    return i;
    }
    };


Log in to reply
 

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