Level
프로그래머스 Lv2
function solution(n, computers) {
  var answer = n;
  const visited = Array(n).fill(0);
  const checkLinkedComputers = (computer) => {
    visited[computer] = 1;

    for (let j = 0; j < n; j++) {
      if (visited[j] === 1) continue;

      const isLinkedComputer = computers[computer][j];
      if (isLinkedComputer) {
        visited[j] = 1;
        checkLinkedComputers(j);
        answer--;
      }
    }
  };

  for (let i = 0; i < n; i++) {
    checkLinkedComputers(i);
  }

  return answer;
}