Problem
Given a reference to a node in a connected undirected graph, return a deep copy of the graph.
References
Difficulty
🟡 Medium
Companies
Amazon, Google, Goldman Sachs
Notes
Language: Java
BFS or DFS with a HashMap<originalNode, clonedNode> to track already-cloned nodes and avoid infinite loops.
Problem
Given a reference to a node in a connected undirected graph, return a deep copy of the graph.
References
Difficulty
🟡 Medium
Companies
Amazon, Google, Goldman Sachs
Notes
Language: Java
BFS or DFS with a HashMap<originalNode, clonedNode> to track already-cloned nodes and avoid infinite loops.