classSolution {// use inorder, inorder must be asc order// cant use Integer.MIN_VALUE, test case has [Integer.MIN_VALUE], // so root.val <= pre will true => then return false, // but it only has on single node [Integer.MIN_VALUE]privateInteger pre =null; publicbooleanisValidBST(TreeNode root) {if (root ==null) returntrue;if (!isValidBST(root.left)) returnfalse; // run leftif (pre !=null&&root.val<= pre) returnfalse; pre =root.val;returnisValidBST(root.right); // run right }}