Problem · Array

Second Distinct Largest Element

Learn this problem
EasyMulticoreWareOA

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[]) → int

Examples

Example 1

nums = [5,1,5,3]return = 3

Example 2

nums = [2,2,1]return = 1

More MulticoreWare problems

drafts saved locally
public int secondLargestDistinct(int[] nums) {
  // write your code here
}
nums[5,1,5,3]
expected3
checking account