Can somebody please tell me what is wrong with my code


  • 0

    public class Solution {

    private static int min=Integer.MIN_VALUE;
    
    public boolean isValidBST(TreeNode root) {
        
        // base case
        if(root==null) return true;
        
        
        // checking for bst by inorder fashion
        if(!isValidBST(root.left))
            return false;
            
         if(root.val<= min)
           return false;
           
           min=root.val;
           
        return isValidBST(root.right);
    
    }
    

    }


Log in to reply
 

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