public boolean isValidBSTRec(TreeNode root, int min, int max){
        if(root == null) return true;
        if(root.val <= min || root.val >= max) return false;
        boolean l = isValidBSTRec(root.left, min, root.val);
        if(!l) return false;
        boolean r = isValidBSTRec(root.right, root.val, max);
        if(!r) return false;
        return true;
    }