Skip to content

Commit e9b2f8f

Browse files
update 323
1 parent 57f11f7 commit e9b2f8f

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

  • src/main/java/com/fishercoder/solutions/firstthousand

‎src/main/java/com/fishercoder/solutions/firstthousand/_323.java‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,20 @@ public int countComponents(int n, int[][] edges) {
2727
for (int i = 0; i < n; i++) {
2828
if (!visited[i]) {
2929
count++;
30-
Queue<Integer> queue = new LinkedList<>();
31-
queue.offer(i);
30+
Queue<Integer> q = new LinkedList<>();
31+
q.offer(i);
3232

33-
while (!queue.isEmpty()) {
34-
int currNode = queue.poll();
33+
while (!q.isEmpty()) {
34+
int currNode = q.poll();
3535
visited[currNode] = true;
3636
for (int neighbor : adj.get(currNode)) {
3737
if (!visited[neighbor]) {
38-
queue.offer(neighbor);
38+
q.offer(neighbor);
3939
}
4040
}
4141
}
4242
}
4343
}
44-
4544
return count;
4645
}
4746
}

0 commit comments

Comments
 (0)