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.
- Prepare
- Python
- Sets
- The Captain's Room
- Discussions
The Captain's Room
The Captain's Room
Sort by
recency
|
1512 Discussions
|
Please Login in order to post a comment
from collections import Counter
grp_size = int(input())
room_nmbrs = Counter(input().split())
caps_room = room_nmbrs.most_common()[-1]
print(caps_room[0])
from collections import Counter
n =int(input())
dict_rooms = Counter(input().split(" "))
cpt_room = dict_rooms.most_common()[::-1]
print(cpt_room[0][0])
Input group size
n = int(input())
Input the list of room numbers
x = list(map(int, input().split()))
Use a set to extract unique room numbers
unique_rooms = set(x)
Use the mathematical approach to calculate the Captain's room
captain_room = (sum(unique_rooms) * n - sum(x)) // (n - 1)
Output the Captain's
print(captain_room)
This is the best answer