LeetCode 138. Copy List with Random Pointer



A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.

Return a deep copy of the list.


We can introduce a map to help us store the relationship between the original list node and the copy version new node.

Whenever we visited an original node, we can check if we have already created a copy version. If created, we use copy version to generate corresponding position new node in the new linked list.

Video Tutorial

Java Solution

Leave a Reply

Your email address will not be published. Required fields are marked *