@@ -0,0 +1,1527 @@
+package com.ctci.treesandgraphs;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * @author rampatra%0A * @since 2019-02-17%0A */%0Apublic class ValidateBST %7B%0A%0A    private static boolean isBST(TreeNode node) %7B%0A        return isBST(node, new ArrayList%3C%3E());%0A    %7D%0A%0A    private static boolean isBST(TreeNode node, List%3CInteger%3E values) %7B%0A        if (node == null) return true;%0A%0A        isBST(node.left, values);%0A        if (values.isEmpty() %7C%7C node.val %3E values.get(values.size() - 1)) %7B%0A            values.add(node.val);%0A        %7D else %7B%0A            return false;%0A        %7D%0A        isBST(node.right, values);%0A%0A        return true;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        TreeNode treeRoot = new TreeNode(1);%0A        treeRoot.left = new TreeNode(2);%0A        treeRoot.right = new TreeNode(3);%0A        System.out.println(%22Is BST: %22 + isBST(treeRoot));%0A%0A        treeRoot = new TreeNode(2);%0A        treeRoot.left = new TreeNode(1);%0A        treeRoot.right = new TreeNode(3);%0A        System.out.println(%22Is BST: %22 + isBST(treeRoot));%0A%0A        treeRoot = new TreeNode(4);%0A        treeRoot.left = new TreeNode(2);%0A        treeRoot.right = new TreeNode(8);%0A        treeRoot.left.left = new TreeNode(1);%0A        treeRoot.left.right = new TreeNode(3);%0A        treeRoot.left.left.left = new TreeNode(0);%0A        treeRoot.right.left = new TreeNode(6);%0A        treeRoot.right.right = new TreeNode(9);%0A        treeRoot.right.left.right = new TreeNode(7);%0A        System.out.println(%22Is BST: %22 + isBST(treeRoot));%0A    %7D%0A%7D%0A

Check BST: 1 approach done