Skip to main content
mediumNeetCode 150

Copy List with Random Pointer

Return a deep copy of the list (new nodes only).

Copy List with Random Pointer is Clone Graph wearing a linked-list costume: random can point anywhere, so you cannot copy in one naive pass. A map from old node to new node lets you wire next and random after every copy exists. The O(1)-space interleaving trick is the flex once the map version clicks.

Linked ListArrays & Hashing

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.

1Copy List with Random Pointermedium
Based onLeetCode