We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Find the Runner-Up Score!
Find the Runner-Up Score!
Sort by
recency
|
8382 Discussions
|
Please Login in order to post a comment
if name == 'main': #bharat n = int(input()) arr = map(int, input().split()) Max,secondMax=-101,-101 for x in arr: if(x>Max): secondMax=Max
Max=x
elif(x>secondMax and x
Sorted and list looks easy and simple but you're taking a toll on space and time. Any interviewer seeing this code will make question you. Always use less time and space solutions. Here is my O(n) Time and O(1) space solution.
if name == 'main': n = int(input()) # number of scores arr = list(map(int, input().split())) # scores list
if name == 'main': n = int(input()) arr = map(int, input().split()) arr=set(arr) arr=list(arr) arr.sort() print(arr[-2])
if name == 'main': n = int(input()) arr = map(int, input().split()) arr=set(arr) arr=list(arr) arr.sort() print(arr[-2])