**Physical Address**

304 North Cardinal St.

Dorchester Center, MA 02124

Mr. Anant Asankhya is the manager at the INFINITE hotel. The hotel has an infinite amount of rooms.

One fine day, a finite number of tourists come to stay at the hotel.

The tourists consist of:

→ A Captain.

→ An unknown group of families consisting of K members per group where K ≠ 1.

The Captain was given a separate room, and the rest were given one room per group.

Mr. Anant has an unordered list of randomly arranged room entries. The list consists of the room numbers for all of the tourists. The room numbers will appear

K times per group except for the Captain’s room.

Mr. Anant needs you to help him find the Captain’s room number.

The total number of tourists or the total number of groups of families is not known to you.

You only know the value of K and the room number list.

The first line consists of an integer, K, the size of each group.

The second line contains the unordered elements of the room number list.

- 1 < K < 1000

Output the Captain’s room number.

**5**
**1** **2** **3** **6** **5** **4** **4** **2** **5** **3** **6** **1** **6** **5** **3** **2** **4** **1** **2** **5** **1** **4** **3** **6** **8** **4** **3** **1** **5** **6** **2**

**8**

The list of room numbers contains 31 elements. Since K is 5, there must be 6 groups of families. In the given list, all of the numbers repeat 5 times except for room number 8.

Hence, 8 is the Captain’s room number.

```
n = int(raw_input());
dic = {}
for x in raw_input().split():
dic[x] = dic.get(x,0) + 1
for key in dic:
if dic[key] != n:
print key
break
```

```
# Enter your code here. Read input from STDIN. Print output to STDOUT
k,arr = int(input()),list(map(int, input().split()))
myset = set(arr)
print(((sum(myset)*k)-(sum(arr)))//(k-1))
```

```
# Enter your code here. Read input from STDIN. Print output to STDOUT
k,arr = input(), list(map(int, raw_input().split()))
s = set(arr)
print ((sum(s)*k)-(sum(arr)))//(k-1)
```

```
counts = dict()
n = input()
number = input().split()
for i in number:
if i not in counts:
counts[i] = 1
else:
counts[i] += 1
for i in counts:
if counts[i] == 1:
print (i)
```

In our experience, we suggest you solve this The captain’s Room Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

The captain’s Room is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get all Hacker Rank Solution

I hope this The captain’s Room Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

**More Hacker Rank Problem & Solutions >>**

Mini-Max Sum Hacker Rank Solution

String Validators Hacker Rank Solution

Text Alignment Hacker Rank solution