jzhangnu / Leetcode-JS-Solutions

:tropical_drink: Leetcode solutions using JavaScript.
52 stars 7 forks source link

215. Kth Largest Element in an Array #116

Open jzhangnu opened 7 years ago

jzhangnu commented 7 years ago
var findKthLargest = function(nums, k) {
    nums = nums.sort(function(a,b){
        return a - b
    })
    console.log(nums)
    return nums[nums.length - k]
};