The Captain's Room Problem Solution

The Captain's Room Problem Solution

Instructor-svgAl-Mamun Sarkar
Mar 24 , 2020

The Captain's Room HackerRank Python Sets problem solution. 

Code:


def coptain_room(rooms, k):
	myset = set(rooms)
	ans = (sum(myset)*k) - sum(rooms)
	return (ans // (k-1))


if __name__ == '__main__':
	k = int( input() )
	rooms = list(map(int, input().split()))
	print(coptain_room(rooms, k))

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram