Validate binary search tree

Write codeMedium16 min

Your task

Given a binary tree as a level-order array (null for missing), determine whether it is a valid binary search tree: every node's value is strictly greater than all values in its left subtree and strictly less than all values in its right subtree. Duplicate values make it invalid. Return true or false.

Examples

is_valid_bst(level: list) -> bool
Example 1
Inputis_valid_bst([2, 1, 3])
OutputTrue