Backend Engineer
Senior
programming
Write a function that returns 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.
Example 1:
Input: nums = [3,2,1,5,6,4], k = 2
Output: 5Example 2:
Input: nums = [3,2,3], k = 1
Output: 3Constraints:
- 1 <= k <= nums.length <= 10^4
- -10^4 <= nums[i] <= 10^4.
Suggested Answer