Simple python recursive implement

  • 0
    class Solution(object):
        def flatten(self, root):
            :type root: TreeNode
            :rtype: void Do not return anything, modify root in-place instead.
            if root is None: return None
            if root.left: 
                right, root.right, root.left = root.right, root.left, None
                p = root.right
                while p and p.right: p = p.right
                p.right = right

Log in to reply

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