Hardware interview practice
Find the two largest distinct values
Return the largest and second-largest distinct integers in an array.
Reviewed example
Work through one case
Input
values = [9, 1, 9, 7, 4]Expected output
largest = 9, second_largest = 7The duplicate 9 does not count as a second distinct value.
What to cover
Requirements
- Assume at least two distinct values exist.
- Use one pass.
- Handle negative values.
