0
点赞
收藏
分享

微信扫一扫

DNS 解析过程

雨鸣静声 2024-05-29 阅读 15

题目:

题解:

class Solution:
def connect(self, root: 'Node') -> 'Node':
if not root:
return None
start = root
while start:
self.last = None
self.nextStart = None
p = start
while p:
if p.left:
self.handle(p.left)
if p.right:
self.handle(p.right)
p = p.next
start = self.nextStart
return root

def handle(self, p):
if self.last:
self.last.next = p
if not self.nextStart:
self.nextStart = p
self.last = p
举报

相关推荐

0 条评论