606.Kth Largest Element II
1.Description(Medium)
Find K-th largest element in an array. and N is much larger than k.
Notice
You can swap elements in the array
Example
In array[9,3,2,4,8]
, the3rd
largest element is4
.
In array[1,2,3,4,5]
, the1st
largest element is5
,2nd
largest element is4
,3rd
largest element is3
and etc.
2.Code
用minheap维护。
Last updated