Why does my code work in the test environment but can not be accepted when submitting?

  • 0
    # Definition for a binary tree node.
    # class TreeNode(object):
    #     def __init__(self, x):
    #         self.val = x
    #         self.left = None
    #         self.right = None
    class Solution(object):
        def convertBST(self, root, sumVal = [0]):
            :type root: TreeNode
            :rtype: TreeNode
            if root:
                self.convertBST(root.right, sumVal)
                sumVal[0], root.val = sumVal[0] + root.val, sumVal[0] + root.val
                self.convertBST(root.left, sumVal)
            return root

Log in to reply

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