题解 | #复杂链表的复制#
复杂链表的复制
http://www.nowcoder.com/practice/f836b2c43afc4b35ad6adc41ec941dba
# -*- 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
node=RandomListNode(None)
head=node
while pHead:
node.next=RandomListNode(pHead.label)
node=node.next
node.next=pHead.next
node.random=pHead.random
pHead=pHead.next
return head.next
查看9道真题和解析
OPPO公司福利 1154人发布