You are viewing a single comment's thread. Return to all comments →
From my HackerRank solutions.
boolean checkBST(Node root) { return checkBST(root, 0, 10000); } boolean checkBST(Node node, int min, int max) { if (node == null) return true; if (node.data < min || node.data > max) return false; return checkBST(node.left, min, node.data - 1) && checkBST(node.right, node.data + 1, max); }
Let me know if you have any questions.
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 →
Java solution - passes 100% of test cases
From my HackerRank solutions.
Let me know if you have any questions.