Create trres1.java - #1756
Conversation
Validate Binary Search Tree (trres1.java)Your solution for the Validate Binary Search Tree problem has several critical issues:
Here's a corrected version using the range approach: public boolean isValidBST(TreeNode root) {
return helper(root, Long.MIN_VALUE, Long.MAX_VALUE);
}
private boolean helper(TreeNode node, long min, long max) {
if (node == null) return true;
if (node.val <= min || node.val >= max) return false;
return helper(node.left, min, node.val) && helper(node.right, node.val, max);
}VERDICT: NEEDS_IMPROVEMENT Construct Binary Tree from Preorder and Inorder TraversalStrengths:
Areas for improvement:
VERDICT: PASS |
No description provided.