DescriptionQ986
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 interpretationInput
values = [9, 1, 9, 7, 4]Output
largest = 9, second_largest = 7Explanation
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.
