@@ -0,0 +1,1014 @@
+/***%0A * Given a binary tree, determine if it is a valid binary search tree (BST).%0A *%0A * Assume a BST is defined as follows:%0A *%0A * The left subtree of a node contains only nodes with keys less than the node's key.%0A * The right subtree of a node contains only nodes with keys greater than the node's key.%0A * Both the left and right subtrees must also be binary search trees.%0A */%0A/**%0A * Definition for binary tree%0A * public class TreeNode %7B%0A *     int val;%0A *     TreeNode left;%0A *     TreeNode right;%0A *     TreeNode(int x) %7B val = x; %7D%0A * %7D%0A */%0Apublic class Solution %7B%0A    // Solution O(n), O(log n)%0A    public boolean isValidBST(TreeNode root) %7B%0A        return isValidBST(root, Long.MIN_VALUE, Long.MAX_VALUE);%0A    %7D%0A    private boolean isValidBST(TreeNode root, long lower, long upper) %7B%0A        if (root == null) return true;%0A        return ((long)root.val %3E lower) && ((long)root.val %3C upper) &&%0A            isValidBST(root.left, lower, root.val) &&%0A            isValidBST(root.right, root.val, upper);%0A    %7D%0A%7D%0A

add ValidateBinarySearchTree.java