[leetcode_215] Kth Largest Element in an Array

第k大数,取巧了,直接快排了。应该是模拟快排。

1
2
3
4
5
6
7
class Solution {
public:
    int findKthLargest(vector<int>& nums, int k) {
        sort(nums.begin(), nums.end(), greater<int>());
        return nums[k - 1];
    }
};
Licensed under CC BY-NC-SA 4.0