215 array of a large number of k

215 Returns an array of a large number of k

A return array of a large number of k

【topic】

Here Insert Picture Description
Here Insert Picture Description

【method one】

Sorting, returns to the k-th number.

Code:

class Solution {
    public int findKthLargest(int[] nums, int k) {
        Arrays.sort(nums);
        return nums[nums.length-k];
    }
}

【Method Two】

【Method Two】

【Method Two】

【Method Two】

Released six original articles · won praise 0 · Views 171

Guess you like

Origin blog.csdn.net/siyuchuanmei2020/article/details/104286767