Skip to content

Commit 84fdd1f

Browse files
add a comment for 684
1 parent 69c6f60 commit 84fdd1f

File tree

1 file changed

+2
-0
lines changed
  • src/main/java/com/fishercoder/solutions/firstthousand

1 file changed

+2
-0
lines changed

Diff for: src/main/java/com/fishercoder/solutions/firstthousand/_684.java

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public static class Solution2 {
9191
* DFS, credit: https://leetcode.com/problems/redundant-connection/editorial/
9292
* 1. we build the graph one edge at a time, each time, we add both edge[0] to the neighbors of edge[1] and vice versa since this is an un-directed graph;
9393
* 2. as soon as we encounter an edge that can connect to each other, it must be the redundant one.
94+
* In other words, we first check if this new edge is needed or not based on the current existing graph:
95+
* if the two nodes connected by this edge is already connected, then this edge is redundant.
9496
*/
9597
private static final int MAX_VERTICES = 1000;
9698

0 commit comments

Comments
 (0)