The Captain's Room

Sort by

recency

|

1540 Discussions

|

  • + 0 comments

    i = int(input())

    list_1 = list(map(int,input().split()))

    list_1.sort()

    x = 0

    while x < len(list_1) - 1:

    if list_1[x] != list_1[x + 1]:
    
        print(list_1[x])
        break
    else:
    
        x += i  # Skip over group
    

    else:

    # If captain is at the end
    print(list_1[-1])
    
  • + 0 comments

    I tried using set since it is from the sets section. Time is exceeding limit, anyone who can optimize this. N=int(input()) m=list(map(int, input().split())) n=set(m) l=[] for i in n: count=0 for j in m: if i==j: count +=1 l.append([i,count])

    for i in l: if i[1]==1: print(i[0])

  • + 0 comments

    Here is HackerRank The Captain's Room in Python solution - https://programmingoneonone.com/hackerrank-the-captains-room-solution-in-python.html

  • + 0 comments

    from collections import Counter

    k = int(input())

    room_list = list(map(int , input().split()))

    room_count = Counter(room_list)

    for room_list , room_members in room_count.items():

        if room_members == 1:
        print(room_list)
    
  • + 0 comments

    from collections import Counter

    k=int(input())

    rn=input().split()

    l=dict(Counter(rn))

    for k,v in l.items():

        if v==1:print(int(k))