Python recursive solution o(n) time

  • 0
    def convertBST(self, root):
            def bst(root, value = 0):
                if root:
                    value = bst(root.right, value)
                    root.val += value
                    value = bst(root.left, root.val)
                    return value
                return value
            return root

Log in to reply

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