← All problems
Clone Graph
Deep-copy a connected undirected graph given a reference node.
Complexity
Time O(n+e), Space O(n)
Common pitfalls
- Infinite recursion on cycles (no map check)
- Shallow copy of neighbor lists
Your solution
Log in to save your code and track progress.