https://programmers.co.kr/learn/courses/30/lessons/43162
for
문으로 컴퓨터별 출석이 안되어있으면 연결된 네트워크 확인을 통해answer
값 1씩 증가.
dfs
함수는 연결되어진 모든 노드를 돌아다니며 확인, 이때 출석체크도 해줌.
def dfs(ith, attendance, computers):
for i in range(len(computers)):
if computers[ith][i]==1 and attendance[i]==False:
attendance[i] = True
dfs(i, attendance, computers)
def solution(n, computers):
answer = 0
attendance = [False] * n
for ith in range(n):
if attendance[ith] == False:
attendance[ith] = True
answer += 1
dfs(ith, attendance, computers)
return answer