Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Validate BST

Python data engineering interview problem. Difficulty: advanced. Pattern: Trees. About 18 minutes. Part of the Pro drill bank.

Check whether a level-order tree is a valid BST. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

Implement is_valid_bst(level_order: list) -> bool. ; [5, 1, 4, None, None, 3, 6] → False.

Constraints

  • Strict BST: left < node < right for all descendants.
  • Duplicates are invalid.

Examples

Input: is_valid_bst([2, 1, 3]) Output: True Classic valid BST.

Topics: lakebench, python, bst, bounds.

More Python interview questions · All interview problems · Learn data engineering

advanced

Validate BST

Interview-style drill: Check whether a level-order tree is a valid BST.

Implement `is_valid_bst(level_order: list) -> bool`. Example: `[2, 1, 3]` → `True`; `[5, 1, 4, None, None, 3, 6]` → `False`. Keep the harness.