Practice Validate Binary Search Tree
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Validate Binary Search Tree
Problem Statement
Determine whether a binary tree is a strict binary search tree. Every value anywhere in a node's left subtree must be smaller than that node; every value in its right subtree must be larger. Apply the same condition recursively. Duplicate values are invalid, even when the immediate parent comparison would appear correct. Practice approach: Carry an exclusive lower and upper bound into each subtree. A node must lie inside both bounds. Alternatively, an inorder traversal must be strictly increasing. Visit each node once: O(n) time and O(h) traversal space.
Source: Validate Binary Search Tree on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
root = [2,1,3]
true
# Example 2
root = [5,1,4,null,null,3,6]
false
Constraints
Related LeetCode Problems
Practice more problems similar to Validate Binary Search Tree.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.