An online auction house records every bid placed on a lot, in the order submitted -- the same bidder, or the same amount, may appear more than once. After the auction closes, the house wants the second-highest DISTINCT bid amount actually placed: the highest bid amount that is strictly less than the top bid amount. If every bid tied at the same value, if there was only one bid, or if there were no bids at all, there is no such runner-up amount.
Print the second-highest distinct bid amount. If it does not exist, print NONE.
Example 1
Input
3 100 200 300
Expected
200
Explanation
The bids placed are 100, 200, and 300, all distinct. The highest is 300 and the second-highest distinct amount is 200.
Example 2
Input
1 100
Expected
NONE
Explanation
The only bid placed is 100, so there is only one distinct amount and no runner-up exists.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →