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
|
1541 Discussions
|
Please Login in order to post a comment
using two sets
a = int(input()) datas = list(map(int,input().split())) seta = set() setb = set() for each in datas: if each not in seta: seta.add(each) setb.add(each) else: #print(each) setb.discard(each)
print(setb.pop())
i = int(input())
list_1 = list(map(int,input().split()))
list_1.sort()
x = 0
while x < len(list_1) - 1:
else:
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])
Here is HackerRank The Captain's Room in Python solution - https://programmingoneonone.com/hackerrank-the-captains-room-solution-in-python.html
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():