JAVA SOLUTION


  • 0
    N

    ...
    class Solution {
    TreeNode preNode;
    public boolean isValidBST(TreeNode root) {
    if(root == null) return true;;
    boolean left = isValidBST(root.left);
    if(!left)return left;
    if(preNode != null && preNode.val >= root.val){
    return false;
    }
    preNode = root;
    return isValidBST(root.right);
    }

    }
    ...


Log in to reply
 

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