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.
So this might not be the best solution and I'm not using any set methods, but it's a solution I came up with and haven't seen on this forum so far so here it is:
defCaptain_room(K,array):array.sort()#See if last room on the list belongs to Captain.ifarray[-1]!=array[-2]:returnarray[-1]#See which room has less than expected number of members.forxinarray:ifarray[0+x*K]!=array[1+x*K]:returnarray[x*K]K=int(input())array=list(map(int,input().split()))print(Captain_room(K,array))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Captain's Room
You are viewing a single comment's thread. Return to all comments →
So this might not be the best solution and I'm not using any set methods, but it's a solution I came up with and haven't seen on this forum so far so here it is: