[C++}My 5 lines solution


  • -1
    Z
    class Solution {
        public:
            int findKthLargest(vector<int>& nums, int k) {
                make_heap(nums.begin(),nums.end());
                while(--k){
                    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.