I have written the following code to check if a tree is a Binary search tree. Please help me check the code:
Okay! The code is edited now. This simple solution was sugge
boolean isBST(TreeNode root, int max, int min) { if (root == null) { return true; } else if (root.val >= max || root.val <= min) { return false; } else { return isBST(root.left, root.val, min) && isBST(root.right, max, root.val); } }
an alternative way solving this problem.. similar with your code