Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ986
Page ↗
Q986FWASIC interview problem

Find the two largest distinct values

TechniquesArrayOne pass
DifficultyEasy
TopicArrays
LanguageSystemVerilog
Requirements3 checkpoints
01

Problem

Return the largest and second-largest distinct integers in an array.

Example input and output

Use this case to check your interpretation
Input
values = [9, 1, 9, 7, 4]
Output
largest = 9, second_largest = 7
Explanation

The duplicate 9 does not count as a second distinct value.

02

Requirements (3)

  • Assume at least two distinct values exist.
  • Use one pass.
  • Handle negative values.