Output in submit and run code are different

  • 3

    I submit my code and got return as wrong answer since it does not pass case [0,-1]. It shows my output is false but it should be true. Then I run code by check customized case [0,-1]. It shows my output is true. Is there anything wrong?

    # 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):
        global pre
        pre = None
        def isValidBST(self, root):
            :type root: TreeNode
            :rtype: bool
            global pre
            if (root == None):
                return True
            if ((not self.isValidBST(root.left)) or (pre != None and pre.val >= root.val)):
                return False
            pre = root
            if (not self.isValidBST(root.right)):
                return False
            return True

  • 0

    Me too! What happens to leetcode? Is it I am wrong?

  • -1

    Please read the FAQ item no. 3.

  • 0

    I am having the same problem. When I testing [0,-1] case in custom testcase it is running fine. But when I am submitting my code the same case is giving different output. Can someone please tell me why?

Log in to reply

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