# -*- coding:utf-8 -*-
# class RandomListNode:
#     def __init__(self, x):
#         self.label = x
#         self.next = None
#         self.random = None
class Solution:
    # 返回 RandomListNode
    def Clone(self, pHead):
        # write code here
        cur = RandomListNode(-1)
        pre = RandomListNode(-1)
        pre.next = cur
        res = []
        while pHead:
            cur.next = RandomListNode(pHead.label)
            cur = cur.next
            cur.random = pHead.random
            pHead = pHead.next
        return pre.next.next

用到字典,先遍历链表,字典存储{节点值:出现次数},然后再次遍历链表,把字典中出现次数超过1次的节点按照顺序创建一个新的链表即可。