My 2-line plain C++ solution using sort


  • -2
    P
    class Solution {
    public:
        int findKthLargest(vector<int>& nums, int k) {
            sort(nums.begin(),nums.end());
            return nums[nums.size()-k];
        }
    };

Log in to reply
 

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