← 返回 meta 的题目列表Find the Kth Largest Element in an Array
类型:online_judge
Given an integer array nums and an integer k, return the kth largest element in the array. You may assume that k is always valid, 1 ≤ k ≤ array's length.
Example:
Input: [3,2,1,5,6,4] and k = 2
Output: 5
Input: [3,2,3,1,2,4,5,5,6] and k = 4
Output: 4
Constraints:
1 <= k <= nums.length <= 10,000
-10,000 <= nums[i] <= 10,000
Example
Input
3 2 1 5 6 4
2