Loading...
Loading...
In a quiz, the prize goes to the top score and a runner-up prize to the second highest different score. If several students tie on top, the runner-up score is the next lower score. Print it, or NONE if every student has the same score.
NONE.Example 1
Input
6 45 78 92 78 92 60
Output
78
The top score is 92 (twice); the next different score is 78.
Example 2
Input
3 50 50 50
Output
NONE
There is no second different score.
Try the problem first. Open one hint at a time.
First find the highest score with one loop.
In a second loop, look for the largest score that is strictly less than the highest.
Use a boolean to remember whether such a score was found at all; do not use a magic number like -1, since scores can be negative.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor