C++ use std::make_heap std::pop_heap


  • 1
    L

    use std::make_heap std::pop_heap 4ms

    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[0];
    }

Log in to reply
 

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