LeetCode . You're given a linked list where each node has a next pointer and a random pointer (which can point to any node or null). Create a deep copy of the entire list. Amazon asks this to test pointer manipulation and hash map usage.
The copy must be entirely new nodes. No pointer in your copy should reference the original list.
If node A's random points to node C in the original, then copy-of-A's random must point to copy-of-C. The challenge: when copying node A, the target of its random pointer might not exist yet. How do you map original nodes to their copies?
Constraints: up to nodes, values from to .