leetcode 215. 数组中的第K个最大元素

链接: https://leetcode-cn.com/problems/kth-largest-element-in-an-array/

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

你可能感兴趣的:(LeetCode,leetcode,算法,职场和发展,后端)