Skip to content

#138 - Copy List with Random Pointer

MediumLinked List
Open on LeetCode

Construct a deep copy of a linked list where each node has an additional random pointer that can point to any node in the list or null.

InputOutput
head = [[7,null],[13,0],[11,4],[10,2],[1,0]][[7,null],[13,0],[11,4],[10,2],[1,0]] (deep copy)
head = [[1,1],[2,1]][[1,1],[2,1]] (deep copy)
head = [[3,null],[3,0],[3,null]][[3,null],[3,0],[3,null]] (deep copy)

Released under the MIT License.