โ† All coding problems

Kth largest element

MediumSorting

Return the kth largest number in nums (counting duplicates, so in [3,3,1] the 2nd largest is 3). 1 <= k <= length.

Function
function solve(nums, k)
Example 1
nums = [3,2,1,5,6,4]
k = 2
โ†’ 5

Submit also runs 3 hidden tests, including edge cases.

console.log output is shown below