Approach hintTry it first, then revealHide
Traverse the graph with DFS or BFS while keeping a hash map from each original node to its copy; create a copy on first visit and connect copied neighbours through the map.
Traverse the graph with DFS or BFS while keeping a hash map from each original node to its copy; create a copy on first visit and connect copied neighbours through the map.