138. Copy List with Random Pointer
Description
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.
Idea
Clone problem is always involved with hashmap which store the mapping from original nodes to new nodes.
Code
1 | # Definition for singly-linked list with a random pointer. |