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.
Your code will show error because when largest number is removed in one iteration, then the next number will be assigned it's index and thus it will become a mess. you could try this
n = int(input())
arr = list(map(int, input().split()))
a = max(arr)
for x in range(len(arr)-1,-1,-1):
if arr[x] == a:
arr.remove(arr[x])
print(max(arr))
Find the Runner-Up Score!
You are viewing a single comment's thread. Return to all comments →
Your code will show error because when largest number is removed in one iteration, then the next number will be assigned it's index and thus it will become a mess. you could try this