03_填充每个节点的下一个右侧节点指针
"""
# Definition for a Node.
class Node(object):
def __init__(self, val, left, right, next):
self.val = val
self.left = left
self.right = right
self.next = next
"""
class Solution(object):
def connect(self, root):
"""
:type root: Node
:rtype: Node
"""
def helper(root):
if not root:
return
if not root.left:
return
root.left.next = root.right
if root.next:
root.right.next = root.next.left
helper(root.left)
helper(root.right)
helper(root)
return root
本文标题:03_填充每个节点的下一个右侧节点指针
本文链接:https://www.haomeiwen.com/subject/uuufictx.html
网友评论