This theory is part of Premium
The full write-up (worked counting examples, the trap list and the interview playbook) unlocks with a Premium plan, along with every Pro visualizer.
See pricingDFS or BFS with a map from original node to its copy, so shared neighbours are copied once.
What this asks
Deep-copy a graph with correct shared neighbours.
A map from original to copy; create the copy on first sight and wire neighbours as the walk returns.
The full write-up (worked counting examples, the trap list and the interview playbook) unlocks with a Premium plan, along with every Pro visualizer.
See pricing