Is It a Valid Search Tree?
A binary tree is given as a level-order array tree with null for missing children.
Return true if it is a valid binary search tree: for every node, every value in its left subtree is strictly smaller than the node and every value in its right subtree is strictly larger. An empty tree is valid. Note that checking only a node against its direct children is not enough.
Example 1
Input: tree = [2,1,3] Output: true
Example 2
Input: tree = [5,4,6,null,null,3,7] Output: false Explanation: 3 is in the right subtree of 5 but is smaller than 5.
Constraints
- 0 <= number of nodes <= 10^4
- -2^31 <= node value <= 2^31 - 1
Hint 1
Carry an allowed (low, high) range down the tree.
Hint 2
Going left tightens the upper bound; going right tightens the lower bound.
Good practice for: Backend Developer, Database Administrator, Full Stack Developer, Data Engineer, Blockchain Developer
Run checks your code on 3 sample tests. Submit runs all 9 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.