Solve problem "The second maximum" online - Learn Python 3 - Snakify

Problem «The second maximum» (Hard)


Statement

The sequence consists of distinct positive integer numbers and ends with the number 0. Determine the value of the second largest element in this sequence. It is guaranteed that the sequence has at least two elements.

In all the problems input the data using input() and print the result using print().



Saved solutions

Tests

Input Correct answer Result
1
7
9
0
7
2
1
0
1
1
2
0
1
1
2
3
0
2
1
3
2
0
2
2
3
1
0
2
2
1
3
0
2
3
1
2
0
2
3
2
1
0
2
1
4
2
3
0
3
1
4
3
2
0
3
4
1
2
3
0
3
4
1
3
2
0
3
10
1
2
3
4
5
6
7
8
9
0
9
1
9
2
3
4
5
6
7
8
10
0
9
9
1
2
3
4
5
6
7
8
10
0
9
9
10
8
7
6
5
4
3
2
1
0
9
10
9
8
7
6
5
4
3
2
1
0
9
1
2
3
4
5
6
7
8
9
10
0
9
2
1
4
3
0
3
2
1
3
4
0
3
1
2
3
4
0
3
1
2
4
3
0
3
3
1
4
2
0
3
3
1
2
4
0
3