Skip to content

Commit fd9da37

Browse files
committed
[level 3] Title: 네트워크, Time: 0.16 ms, Memory: 89.7 MB -BaekjoonHub
1 parent 0c97188 commit fd9da37

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

프로그래머스/3/43162. 네트워크/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 86.3 MB, 시간: 0.76 ms
7+
메모리: 89.7 MB, 시간: 0.16 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2025년 09월 18일 14:19:05
19+
2025년 09월 22일 22:41:55
2020

2121
### 문제 설명
2222

프로그래머스/3/43162. 네트워크/네트워크.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)