FreeCareerPath
Build the PrimitiveMedium

Validate Binary Search Tree

Write `is_valid_bst(root)` returning `True` when every node in the left subtree is strictly less than the node, and every node in the right subtree is strictly greater — for *all* nodes, not just immediate children. [5,1,4,null,null,3,6] -> False (3 sits right of 5) Comparing each node against its parent is the classic wrong answer: it accepts a tree where a deep descendant violates an ancestor's bound. Pass a (low, high) range down instead, narrowing it at each step.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Validate Binary Search Tree" are saved to your account — logging in takes a few seconds.

Validate Binary Search Tree — FreeCareerPath