@@ -0,0 +1,1018 @@
+// 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.%0A%0A// Return a deep copy of the list.%0A%0A/**%0A * Definition for singly-linked list with a random pointer.%0A * class RandomListNode %7B%0A *     int label;%0A *     RandomListNode next, random;%0A *     RandomListNode(int x) %7B this.label = x; %7D%0A * %7D;%0A */%0A%0Apublic class Solution %7B%0A    public RandomListNode copyRandomList(RandomListNode head) %7B%0A    %09if(head == null) return head;%0A%0A    %09HashMap%3CRandomListNode, RandomListNode%3E map = new HashMap%3CRandomListNode, RandomListNode%3E();%0A    %09RandomListNode runner = head;%0A%0A    %09while(runner != null)%7B%0A    %09%09RandomListNode copy = new RandomListNode(runner.label);%0A    %09%09map.put(runner, copy);%0A    %09%09runner = runner.next;%0A    %09%7D    %0A%0A    %09runner = head;%0A%0A    %09while(runner != null)%7B%0A    %09%09map.get(runner).next = map.get(runner.next);%0A    %09%09map.get(runner).random = map.get(runner.random);%0A    %09%09runner = runner.next;%0A    %09%7D%0A%0A    %09return map.get(head);%0A    %7D%0A%7D

add copy list with random pointer solution