Each node in the list contains a next pointer and a random pointer that may point to any node in the list or null.
Return a deep copy of the list.
For the Cheetcode runner, represent the list as pairs of [value, randomIndex].
The randomIndex is either null or the zero-based index of the random target in the original list.
Work with node references instead of array indexes. Make sure you preserve the next pointers you still need before changing links.
Examples
Input: head = [[7,null],[13,0],[11,4],[10,2],[1,0]] Output: [[7,null],[13,0],[11,4],[10,2],[1,0]]
Input: head = [[1,1],[2,1]] Output: [[1,1],[2,1]]
Constraints
- 0 <= n <= 1,000
- -10,000 <= Node.val <= 10,000