3-line C++ solution


  • 0
    G
        int findKthLargest(vector<int>& nums, int k) {
            priority_queue<int, vector<int>> pq_nums(nums.begin(), nums.end());
            while (k-- > 1) pq_nums.pop();
            return pq_nums.top();
        }
    

Log in to reply
 

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