Practice

Second Highest Distinct Score

MEDIUMArrays8 marks

Read N scores into an array, where N is between 3 and 10.

Output the highest score and the second highest distinct score. If all scores are the same, output No second highest after the highest score.

Input: N followed by N integer scores. Output: Highest score, then second highest distinct score or No second highest.

Example:

Input:  6
        7
        9
        9
        3
        6
        7
Output: Highest: 9
        Second: 7
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: Duplicate highest score
Inputs: 6, 7, 9, 9, 3, 6, 7
Expected: Highest: 9 Second: 7
Test 2: All values equal
Inputs: 4, 5, 5, 5, 5
Expected: Highest: 5 No second highest