You are viewing a single comment's thread. Return to all comments →
My Java 8 Solution
boolean checkBST(Node root) { return isBST(root, null, null); } boolean isBST(Node root, Integer min, Integer max) { if (root == null) { return true; } if ((min != null && root.data <= min) || (max != null && root.data >= max)) { return false; } return isBST(root.left, min, root.data) && isBST(root.right, root.data, max); }
Seems like cookies are disabled on this browser, please enable them to open this website
Is This a Binary Search Tree?
You are viewing a single comment's thread. Return to all comments →
My Java 8 Solution