1<\/strong>.<\/p>\n\n\n\nThe Captain was given a separate room, and the rest were given one room per group.<\/p>\n\n\n\n
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<\/strong><\/em> times per group except for the Captain’s room.<\/p>\n\n\n\nMr. 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.<\/em>
You only know the value of <\/em>K<\/em><\/strong> and the room number list.<\/em><\/p>\n\n\n\n<\/span>Input Format<\/strong><\/span><\/h2>\n\n\n\nThe first line consists of an integer, K<\/strong><\/em>, the size of each group.
The second line contains the unordered elements of the room number list.<\/p>\n\n\n\n<\/span>Constraints<\/strong><\/span><\/h2>\n\n\n\n- 1 < K<\/em> < 1000<\/strong><\/li><\/ul>\n\n\n\n
<\/span>Output Format<\/strong><\/span><\/h2>\n\n\n\nOutput the Captain’s room number.<\/p>\n\n\n\n
Sample Input <\/strong><\/p>\n\n\n\n5\n1 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 <\/code><\/pre>\n\n\n\nSample Output<\/strong><\/p>\n\n\n\n8<\/code><\/pre>\n\n\n\nExplanation<\/strong><\/p>\n\n\n\nThe list of room numbers contains 31<\/strong> elements. Since K<\/strong><\/em> is 5<\/strong>, there must be 6<\/strong> groups of families. In the given list, all of the numbers repeat 5<\/strong> times except for room number 8<\/strong>.
Hence, 8<\/strong> is the Captain’s room number.<\/p>\n\n\n\n<\/span>Solution – The Captain’s Room in Python<\/strong><\/span><\/h2>\n\n\n\n# Enter your code here. Read input from STDIN. Print output to STDOUT\nN = input()\nROOM_LIST = input().split()\nROOM_SET = set(ROOM_LIST)\n\nfor ele in list(ROOM_SET):\n ROOM_LIST.remove(ele)\n\nCAPTAIN_ROOM_NUM = ROOM_SET.difference(set(ROOM_LIST)).pop()\nprint(CAPTAIN_ROOM_NUM)<\/pre>\n\n\n\n