Python simple recurison


  • 0
    W
    def flatten(self, root):
        if not root: return
        left, right = root.left, root.right
        self.flatten(left)
        self.flatten(right)
        root.left = None
        if left:
            root.right = left
            while root.right:
                root = root.right
        root.right = right

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.