You are viewing a single comment's thread. Return to all comments →
This... shouldn't work.
set() is a hashset and has no fixed order. it should be sorted() instead of list()
print(sorted(reversed(sorted(set(types))), key=types.count)[-1])
Because there are only 5 types of birds, it can just be
print(sorted(list("54321"), key=types.count)[-1])
Here's my solution:
input() types=input().split() print(-max((types.count(i),-int(i)) for i in set(types))[1])
Migratory Birds
You are viewing a single comment's thread. Return to all comments →
This... shouldn't work.
set() is a hashset and has no fixed order. it should be sorted() instead of list()
Because there are only 5 types of birds, it can just be
Here's my solution: