Given a reference to a node in a connected undirected graph, return a deep copy. The key insight is using a hashmap to track cloned nodes and avoid infinite loops.
💡 Pro tip: Understand this problem deeply — don't just memorize the code. Try explaining the approach out loud as if teaching a friend. If you can explain it simply, you truly understand it!
Run your code
1: [2, 4]
2: [1, 3]
3: [2, 4]
4: [1, 3]