Given an array of integers nums with at least one element, return the second largest distinct element. If no second distinct element exists, return -1.
For example, given [3, 1, 4, 1, 5, 9], the largest is 9 and the second largest distinct value is 5.
Given [7, 7, 7], all elements are the same so there is no second distinct element — return -1.
nums = [3, 1, 4, 1, 5, 9]5nums = [7, 7, 7]-1nums = [10, 5]51 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^9Run your code to see results
Use Cmd+Enter to run