The adjacency list representation tripped me up for a second because you have to track visited nodes or you'll loop forever on cycles.
Use a hash map to track original nodes to their copies, then perform a depth-first search (DFS) or breadth-first search (BFS) from the starting node. For each node, create a copy if it doesn't exist, then recursively (or iteratively) copy all its neighbors and link them to the copy.
Pro tip: Clarify whether the graph can have cycles or duplicate edges, as this affects the need for a visited map. Mention that you'd handle disconnected graphs by iterating over all nodes if the entire graph isn't reachable from the start.
Ask about graph size, cycles, self-loops, and whether the graph is connected. Confirm that a deep copy means new nodes with the same values and neighbor relationships.
Decide between DFS (recursive or iterative) and BFS. Use a hash map (dictionary) to map original nodes to their copies to avoid infinite loops and duplicate work.
Write a function that takes a node, checks if it's already copied, creates a new node if not, and then recursively copies all neighbors and adds them to the new node's neighbor list.
If the graph may not be fully reachable from the start, iterate over all nodes and apply the copy function to each unvisited node.
Test with simple graphs, cycles, and large graphs. State that time and space complexity are O(N + E) where N is number of nodes and E is number of edges.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.