runner up python

Solutions on MaxInterview for runner up python by the best coders in the world

showing results for - "runner up python"
Christy
15 Jan 2020
1n = int(input())
2arr = list(map(int, input().split()))
3if arr[0]!=arr[1]:
4    mx=max(arr[0],arr[1])
5    second_max=min(arr[0],arr[1])
6    for i in range(2,n):    
7        if arr[i]>mx:
8            second_max=mx
9            mx=arr[i]
10        elif arr[i]>second_max and arr[i]!=mx:
11            second_max=arr[i]
12elif arr[0]==arr[1]:
13    mx=max(arr[0],arr[1])
14    second_max=[]
15    for i in range(2,n):
16        if arr[i]>mx:
17            mx=arr[i]
18        elif arr[i]<mx and arr[i]!=second_max:
19            second_max=arr[i]
20        elif arr[-1]>mx:
21            second_max=mx
22            mx=arr[i]
23print(second_max)
24#looks a lot but easy to understand i guess
25#jt272525@gmail.com contact me 
26