My Blog List

[Leetcode Solution] Copy List with Random Pointer

Analysis

  • Pass one, copy the original linked list without random pointer. Store the corresponding relationship between each node in old list and each node in new list by a map
  • Pass two, traversal the list and copy random pointer by map

Code