What does this input mean?

  • 0

    My program got rejected by the following test input (69 of 74):

    Input: [10,5,15,null,null,6,20]

    Output: true

    Expected: false

    No idea about what the null's do in this case and what kind of BST was built from the input? why it fails my program? Thanks.

     public boolean isValidBST(TreeNode root) {
    	if (root==null)	return true;;
        if (root.left!=null) {
        	if (root.val <= root.left.val)	return false;       	
        	if (!isValidBST(root.left))		return false;
        if (root.right!=null) {
        	if (root.val >= root.right.val)	return false;       	
        	if (!isValidBST(root.right))	return false;
        return true;

Log in to reply

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