def copyRandomList(self, head):
if None == head: return None
phead = head
while phead:
pnext = phead.next
phead.next = RandomListNode(phead.label)
phead.next.next = pnext
phead = pnext phead = head
while phead:
if phead.random:
phead.next.random = phead.random.next
phead = phead.next.next head2 = RandomListNode(-1)
tail2 = head2
phead = head
while phead:
tail2.next = phead.next
phead.next = phead.next.next
phead = phead.next
tail2 = tail2.next
return head2.next
版权声明:本文博客原创文章,博客,未经同意,不得转载。