215. Kth Largest Element in an Array

desciption:
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.

解法一:
時間複雜度O(NlogN),空間複雜度O(1)
`public static int findKthLargest(int[] nums, int k) {

    Arrays.sort(nums);
    return nums[nums.length-k];

}`

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章