103. Kth Largest Element in an Array

Find the k-th largest element in an unsorted array.
Example 1
Input: nums = [3,2,1,5,6,4], k = 2
Output: 5
Explanation: The second largest element is 5.
Example 2
Input: nums = [3,2,3,1,2,4,5,5,6], k = 4
Output: 4
Explanation: The fourth largest element is 4.
arraysheapmedium
JavaScript
Loading...
Line 1, Char 1