Created
September 21, 2019 18:27
-
-
Save AhnMo/2f95fd7a229b057dc94f4f63a61d1f4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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