Arrays.sort(nums);returnnums[nums.length - k]; }/** * 分治的思想,利用partition的过程结果,第k的数,在排序后的len - k的位置。 */publicintfindKthLargest(int[] nums,intk){intlen=nums.length;intgoal=len - k;intleft=0, right = len -1;intindex=partition(nums, left, right);while(inde...
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. 思路: 回顾quick sort https://www.cse.ust.hk/~dekai/271/notes/L01a/quickSort.pdf...