Given an integer array nums and an integer k, return the kth largest element in the array.
Note that it is the kth largest element in sorted order, not the kth distinct element.
nums)kInput:
[3,2,1,5,6,4]
2
Output: 5
Input:
[3,2,3,1,2,4,5,5,6]
4
Output: 4
Your program must print a single integer representing the kth largest element.
No submissions yet.
Discuss heap-based solutions, quickselect, and time complexity trade-offs.