← All problems

Validate Binary Search Tree

Medium treesbstrecursion LeetCode ↗
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.

Hints (0/3 revealed)

Log in to reveal hints progressively.

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.