private long min = Long.MIN_VALUE;
public boolean isValidBST(TreeNode root) {
if (root == null) return true;
if (!isValidBST(root.left)){
return false;
}
if (min < root.val) {
min = root.val;
} else {
return false;
}
if (!isValidBST(root.right)){
return false;
}
return true;
}