Kth Largest Element In An Array
Return the kth largest value in nums, counting repeated values separately.
Example 1
nums = [4,1,7,7,2]
k = 27Explanation
Descending order is 7,7,4,2,1; duplicates count, making the second value 7.
Example 2
nums = [3,2,1]
k = 31Explanation
The third largest among three values is minimum 1.
Example 3
nums = [-4]
k = 1-4Explanation
The sole negative value is also largest.
Constraints
- 1 <= k <= len(nums) <= 100000
- Values are -10000..10000
Function contract
findKthLargestArguments: json, jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
[4,1,7,7,2]2