Find 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.
For example,
Given [3,2,1,5,6,4] and k = 2, return 5.
Note:
You may assume k is always valid, 1 ≤ k ≤ array’s length.
Credits:
Special thanks to @mithmatt for adding this problem and creating all test cases.
找出数组中第K大的元素
本文介绍了一种算法问题——在未排序数组中找到第K大的元素。这个问题要求找到数组排序后的第K大元素而非第K个不同的元素。举例说明了当数组为[3,2,1,5,6,4]且K=2时,答案为5。
885

被折叠的 条评论
为什么被折叠?



