A linked list of length n is given where each node has an additional random pointer that can point to any node in the list, or null.
Construct a deep copy of the list. Each node in the new list must have the same val as the corresponding original node, with its next pointer pointing to the correct new node, and its random pointer pointing to the correct new node (not the original). If a node's random pointer is null, the corresponding copy's random pointer is also null.
Return the head of the copied list.
Original: Node(7) -> Node(13) -> Node(11) -> Node(10) -> Node(1) -> null random: null 7 13 11 7
Input: head = [[7, null], [13, 0], [11, 4], [10, 2], [1, 0]] Output: [[7, null], [13, 0], [11, 4], [10, 2], [1, 0]] Explanation: Each pair is [val, index of random node (0-indexed)], or null if no random pointer. The deep copy has the same structure.
Input: head = [[1, 1], [2, 1]] Output: [[1, 1], [2, 1]] Explanation: Both nodes' random pointers point to node at index 1 (the second node). The copy preserves this structure.
head = [[7, null], [13, 0], [11, 4], [10, 2], [1, 0]]