Graphs pattern
Redundant Connection
A tree of n nodes had one extra edge added, creating exactly one cycle. Given the edges in input order, return the edge that can be removed so the result is again a tree, the last edge (in input order) that closes a cycle. Watch it run step by step, then write your own pseudocode and get it checked by AI.
- LeetCode 684
- Medium
- 1 approach
Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.
GraphsLeetCode 684
Medium
The approach
- 01 Union-Find detects the cycle O(n·α(n))O(n) space
What you will learn
- How to read Redundant Connection and spot the graphs pattern in it
- Union-Find detects the cycle: O(n·α(n)) time, O(n) space
- The pseudocode for each approach, its line lit as the animation runs
- Practice: write your own pseudocode and get it checked
More Graphs
See Redundant Connection run, step by step
Sign in and this page opens on the animation, with all 9 Graphs problems beside it.
DSA comes with the all labs plan and every ChaiCode batch.