simple c++ solution with O(n)


  • 0
    K

    sort then loop.

            sort(citations.begin(), citations.end(), [] (int x, int y){return x > y; });
            for (int i = 0; i < citations.size(); i++)
            {   
                if (i >= citations[i])
                    return i;
            }
            return citations.size();

Log in to reply
 

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