You are viewing a single comment's thread. Return to all comments →
Python O(N) solution with no hardcoding the number below minimal:
if __name__ == '__main__': n = int(input()) arr = list(map(int, input().split())) runner_up = first = arr[0] for i in arr[1:]: if i > first: runner_up, first = first, i continue if runner_up < i < first: runner_up = i elif i < runner_up == first: runner_up = i print(runner_up)
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 →
Python O(N) solution with no hardcoding the number below minimal: