249. Second Largest
Print the second largest DISTINCT value among n integers. If every value
is the same, print None.
Distinct matters. In 5 5 4 the answer is 4, not 5, because the two fives are
one distinct value.
You can sort and walk backwards, which is O(n log n). You can also do it in
one pass with two variables, which is O(n) and is the version worth being
able to write: it is the same idea as finding a maximum, with a second slot.
Constraints - `1 ≤ n ≤ 200000` - `-1000000000 ≤ a[i] ≤ 1000000000`
Input
The first line contains an integer n.
The second line contains n integers.
Output
Print the second largest distinct value, or None if there is no second distinct value.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.