Arrays.sort Java Solution


  • 0
    S
    public class Solution {
        public int findKthLargest(int[] nums, int k) {
            Arrays.sort(nums);
            for(int i=nums.length-1,j=1;i>=0;i--,j++) {
                if(k==j) return nums[i];
            }
            //if((nums.length-1-k)<0) return nums[0];
            return nums[0];
        }
    }
    

Log in to reply
 

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