Skip to content

Instantly share code, notes, and snippets.

@AhnMo
Created September 21, 2019 18:27
Show Gist options
  • Save AhnMo/2f95fd7a229b057dc94f4f63a61d1f4c to your computer and use it in GitHub Desktop.
Save AhnMo/2f95fd7a229b057dc94f4f63a61d1f4c to your computer and use it in GitHub Desktop.
def solution(n, computers):
network = [0 for _ in range(n)]
done = False
no = 0
for idx in range(n):
if network[idx] == 0:
no += 1
current = no
else:
current = network[idx]
computer = computers[idx]
for i in range(n):
if computer[i] == 1:
network[i] = current
done = True
for i in network:
if i == 0:
done = False
break
return no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment