Name the Runner-Up

Intermediate

A leaderboard shows not just the winner but the runner-up. Given scores with possible ties at the top, return the second-largest distinct score.

Implement `solve(List<Integer> nums)` (at least two distinct values) to return the second-largest distinct value.

Examples

Input[10, 5, 20, 20, 8]
Output10
Input[1, 2]
Output1
Hints
  • Track the largest and second-largest as you scan; skip duplicates of the max.
Anonymous Apex

Your code runs in a secure sandbox against multiple hidden test cases. The problem is solved only when every test passes. Each run is isolated and any data changes are rolled back automatically.