File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed
Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 86.3 MB, 시간: 0.76 ms
7+ 메모리: 89.7 MB, 시간: 0.16 ms
88
99### 구분
1010
1616
1717### 제출 일자
1818
19- 2025년 09월 18일 14:19:05
19+ 2025년 09월 22일 22:41:55
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change @@ -4,27 +4,27 @@ class Solution {
44 boolean [] visited ;
55 public int solution (int n , int [][] computers ) {
66 visited = new boolean [n ];
7+
78 int answer = 0 ;
8- for (int i = 0 ; i < n ; i ++){
9- if (!visited [i ]){
9+
10+ for (int i = 0 ; i < n ; i ++){
11+ if (!visited [i ]) {
1012 dfs (i ,computers );
11- answer ++;
13+ answer ++;
1214 }
1315 }
1416
1517 return answer ;
1618 }
1719
18- void dfs (int idx , int [][] computers ) {
20+ void dfs (int node , int [][] computers ){
1921
20- int [] computer = computers [idx ];
21-
22- for (int i =0 ; i < computer .length ; i ++) {
23- // 연결된 컴퓨터를 찾음
24- if (computer [i ] == 1 && !visited [i ]) {
25- visited [idx ] = true ;
22+ int [] computer = computers [node ];
23+ for (int i = 0 ; i < computer .length ; i ++) {
24+ if (!visited [i ] && computer [i ] == 1 ){
25+ visited [i ] = true ;
2626 dfs (i ,computers );
27- }
27+ }
2828 }
2929 }
3030}
You can’t perform that action at this time.
0 commit comments