Kth Largest Element

00:00
MediumArrayHeapQuickSelectSorting
AmazonMicrosoft

Find the kth largest element in an unsorted array. It's the kth largest in sorted order (not kth distinct).

Examples

Input → [3,2,1,5,6,4], k=2
Output → 5
Input → [3,2,3,1,2,4,5,5,6], k=4
Output → 4
Input → [1], k=1
Output → 1