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
|
8433 Discussions
|
Please Login in order to post a comment
if name == 'main': n = int(input()) arr = map(int, input().split())
runner_up = sorted(set(arr))
print(runner_up[-2])
"""" set(arr) → removes duplicate scores (like multiple 6’s). sorted(...) → sorts the unique scores in ascending order. sorted_arr[-2] → accesses the second last (runner-up) element. """"
if name == 'main': rev = set() n = int(input()) arr = list(map(int, input().split())) rev = set(arr) arr=list(rev) arr.sort(reverse=True) print(arr[1])
if name == 'main': n = int(input()) arr = map(int, input().split())
#find the second hight score number #print it out
Something I got confused about while working on this problem was actually understanding what the term "runner-up score" means. This was a bit confusing for me. The second thing I wasn't sure about was how to create a list for the "arr." However, in the end, I understood that we do need to have a list. But did we convert the "arr" to a list?