The Captain's Room

Sort by

recency

|

1512 Discussions

|

  • + 0 comments

    from collections import Counter

    grp_size = int(input())

    room_nmbrs = Counter(input().split())

    caps_room = room_nmbrs.most_common()[-1]

    print(caps_room[0])

  • + 0 comments

    from collections import Counter

    n =int(input())

    dict_rooms = Counter(input().split(" "))

    cpt_room = dict_rooms.most_common()[::-1]

    print(cpt_room[0][0])

  • + 1 comment

    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

  • + 0 comments
    tourist_rooms = list(map(int,input().split()))
    
    captain_room =None
    
    if group_size in range(1,1000):
        unique_rooms = list(set(tourist_rooms))
        for room in unique_rooms:
            tourist_rooms.pop(tourist_rooms.index(room))
            if room not in tourist_rooms:
                captain_room = room
            else:
                pass
                
    print(captain_room)
    
  • + 0 comments
    from collections import defaultdict
    
    dd = defaultdict(int)
    mem = int(input())
    ll = list(map(int,input().split()))
    for v in ll:
        if v in dd.keys():
            dd[v]=dd[v]+1
        else:
            dd[v]=1
    
    for k,v in dd.items():
        if v==1:
            print(k)