Skip to main content
mediumBlind 75

Clone Graph

Return a deep copy of the connected undirected graph reachable from node.

Clone Graph is the canonical visited-map problem: as you DFS, a map from old node to new node both stops infinite loops and wires up the copied edges. Skip the map and a cycle sends you spinning forever. Once you see why one structure does double duty, most graph-copy problems collapse into it.

GraphsBFS / DFS

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.

1Clone Graphmedium
Based onLeetCode