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
|
7645 Discussions
|
Please Login in order to post a comment
My code did succeed the test case, but I feel like this isn't the way they intended, since it feels too easy?
list = sorted(arr) second_max = [i for i in list if i!=max(list)] print(second_max[-1])
Not the most clean but worked if name == 'main': n = int(input()) arr = map(int, input().split()) list = [] for num in arr: list.append(num) list.sort() list_unique = [] for num in list: actual = num if actual not in list_unique: list_unique.append(num) list_unique.sort() print(list_unique[len(list_unique)-2])
Looks pretty easy but challenges you to think deeper
if name == 'main': n = int(input()) arr = map(int, input().split())
Can Chcek this n = int(input()) arr = map(int, input().split()) ar = list(arr) ar.sort() mx = max(ar)
cc = ar.count(mx) result = ar.pop(n-1-cc) print(result)