AN ELEGANT HEAP C++ SOLUTION


  • 0
    C
        int findKthLargest(vector<int>& nums, int k) {
            make_heap(nums.begin(), nums.end());
            for(int i = 1; i < k; i++)
            {
                pop_heap(nums.begin(), nums.end());
                nums.pop_back();
            }
            return(nums.front());
        }
    

Log in to reply
 

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