Validate a Binary Search Tree

Medium · Binary Search Trees · about 15 minutes

Asked at Amazon, Meta, Microsoft, Bloomberg, LinkedIn, Grammarly, Quora.

Decide whether a binary tree obeys the binary-search-tree rule at every node: all values in the node's left subtree are strictly smaller than it, all values in its right subtree are strictly larger, and the same holds recursively for both subtrees.

Related guides