LeetCode 98 ·
Medium
Validate Binary Search Tree
Return true if the tree is a valid binary search tree.
Try it
Step through the core mechanic. The simulator below runs the recursion shape this problem is built on.
Walk the pattern
No dedicated step-through for this one yet. The shape is Recursion — its pattern page has the interactive walkthrough, the reference implementation, and a five-problem progression that this problem sits inside.
The approach
Recurse carrying an open (low, high) interval. A node must lie strictly inside; the left child tightens high to the node value, the right child tightens low. Checking only parent–child is the classic bug.
| Aspect | Value |
|---|---|
| Pattern | Recursion |
| Recognise it by | Every node within an inherited (low, high) bound. |
| Time complexity | O(n) |
| Space complexity | O(h) |
| Difficulty | Medium |
Who asks it
Companies known to ask this problem, from public LeetCode company-tag aggregations. A signal of where to expect it, not a guarantee.