You are viewing a single comment's thread. Return to all comments →
GO WITH THIS which does it include any sort or set func ...T.C of O(n) rather than O(logn) for sorting it
if name == 'main': n = int(input()) arr = map(int, input().split()) list1 = list(set(arr)) max=max(list1[0],list1[1]) secondmax=min(list1[0],list1[1])
for i in range(2,len(list1)): if list1[i]>max: secondmax=max max=list1[i] else: if list1[i]>secondmax: secondmax=list1[i] print(secondmax)
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Runner-Up Score!
You are viewing a single comment's thread. Return to all comments →
GO WITH THIS which does it include any sort or set func ...T.C of O(n) rather than O(logn) for sorting it
if name == 'main': n = int(input()) arr = map(int, input().split()) list1 = list(set(arr)) max=max(list1[0],list1[1]) secondmax=min(list1[0],list1[1])