BST Validation
The robust approach is to carry a valid numeric range down the tree. Each node must fall strictly between its inherited lower and upper bounds under the standard no-duplicates BST definition. Checking only the immediate left and right child is insufficient because BST violations can occur deeper in a subtree.
Carry lower and upper bounds to every subtree.
Left subtree updates the upper bound.
Right subtree updates the lower bound.
Time complexity: O(n).
Space complexity: O(h) due to recursion.
The duplicate policy must be explicitly defined.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience