You are viewing a single comment's thread. Return to all comments →
a O(n) one pass solution
if __name__ == '__main__': n = int(input()) arr = map(int, input().split()) if n < 2: raise Exception("not found") import sys max_score = -sys.maxsize result = -sys.maxsize for a in arr: if a > max_score: result = max_score max_score = a elif a > result and a < max_score: result = a print(result)
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 →
a O(n) one pass solution