본문 바로가기
알고리즘

K th largest element in an Array

by e-pd 2020. 8. 25.

 

https://leetcode.com/problems/kth-largest-element-in-an-array/submissions/

 

Kth Largest Element in an Array - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

1
2
3
4
5
6
class Solution {
    public int findKthLargest(int[] nums, int k) {
        Arrays.sort(nums);
        return nums[nums.length - k];
    }
}
cs

 

'알고리즘' 카테고리의 다른 글

Char length count  (0) 2020.08.25
Valid Anagram  (0) 2020.08.25
Unique한 문자인가  (0) 2020.08.24
String to Num  (0) 2020.08.24
정수 내림차순으로 배치하기  (0) 2020.08.22