O(nlogn) solution, runs in 4ms, 2 lines of code


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

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.