← All problems
Validate Binary Search Tree
Determine whether a binary tree is a valid binary search tree: for every node, all values in its left subtree must be strictly less than the node's value, and all values in its right subtree strictly greater.
Complexity
Time O(n), Space O(h)
Common pitfalls
- Only comparing with parent (grandparent violations missed)
- Integer overflow with INT_MIN bounds
Your solution
Log in to save your code and track progress.