Deviopath › JavaScript

Second Largest Number

Medium · Arrays

Write a function secondLargest that returns the second largest distinct value in the array.

Duplicates count once, so in [4, 4, 3] the answer is 3. If there is no second distinct value, return null.

Next: Rotate an Array