Second Distinct Largest Element
Problem statement
Given an integer array nums containing at least two distinct values, return its second-largest distinct value.
Repeated occurrences of the largest value do not count as a separate value.
Function
secondLargestDistinct(nums: int[]) → intExamples
Example 1
nums = [5,1,5,3]return = 3Example 2
nums = [2,2,1]return = 1Source note: Author-written prompt excerpt retained for source fidelity.