本文共 684 字,大约阅读时间需要 2 分钟。
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
转载地址:http://xumji.baihongyu.com/