题目:
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.
说实话这道题我还是挺迷惑的,因为题目并没有要求不能排序,所以不知道为啥还有medium的难度 。
class Solution {
public:
int findKthLargest(vector<int>& nums, int k) {
sort(begin(nums), end(nums));
return nums[nums.size()-k];
}
};