인프런 커뮤니티 질문&답변
답을 String으로 출력하는 이유가 궁금합니다
작성
·
335
0
check[i] == 1 인경우 i를 출력하게 했는데 답은 같게 나옵니다. 그런데도 String temp에 값을 넣어 출력하는 이유가 궁금합니다.
private static void dfs(int depth) {
if(depth == number +1) {
for (int i = 1; i <= number; i++) {
if(check[i] == 1)
System.out.print(i + " ");
}
System.out.println();
return;
} else {
check[depth] = 1;
dfs(depth + 1);
check[depth] = 0;
dfs(depth + 1);
}
}




