Back to DSA
Copy List with Random Pointer
hardA linked list is given in which each node has, in addition to a normal next pointer, a random pointer that can reference any node in the list or be null. Create a complete deep copy of this list. The new list must be structurally identical — each copied node's random pointer must reference the corresponding copied node, not the original.
Examples
Example 1:
Input:
head = [[3,null],[6,0],[9,2],[12,1]]Output:
[[3,null],[6,0],[9,2],[12,1]]Hints
1234567