https://programmers.co.kr/learn/courses/30/lessons/43162
import java.util.*;
class Solution {
static int board[][];
static boolean visit[];
static int cnt;
static int num;
public int solution(int n, int[][] computers) {
num=n;
visit = new boolean[n];
board = computers;
cnt=0;
for(int i=0;i<n;i++){
if(!visit[i]){
cnt++;
dfs(i);
}
}
return cnt;
}
public void dfs(int start){
visit[start] = true;
for(int i=0;i<num;i++){
if(!visit[i]&&board[start][i]==1){
dfs(i);
}
}
}
}