โ† All coding problems

Second largest number

EasyArrays

Return the second largest DISTINCT number in nums. If there is none (fewer than two distinct values), return -1.

Function
function solve(nums)
Example 1
nums = [10,5,8,10]
โ†’ 8

Submit also runs 4 hidden tests, including edge cases.

console.log output is shown below