35 复杂链表的复制
class Solution {
Map<Node, Node> mapOfNode = new HashMap<Node, Node>();
public Node copyRandomList(Node head) {
if(head == null) return null;
while(!mapOfNode.containsKey(head)){
Node headNew = new Node(head.val);
mapOfNode.put(head, headNew);
headNew.next = copyRandomList(head.next);
headNew.random = copyRandomList(head.random);
}
return mapOfNode.get(head);
}
}//offer