Standard Bar Binary Search Trees · Practice Problems O(n) · O(h)
A warehouse's sort racks claim the strict smaller-left, larger-right layout, but a recent retrofit may have wedged crates into the wrong aisles. The auditor walks each station carrying a permissible value window: entering a left aisle tightens the ceiling, entering a right aisle raises the floor. Any crate outside its inherited window fails the audit on the spot.
Input: A binary tree as a level-order array (null marks a missing child) — not guaranteed to be a BST.
Output: Return true if the tree satisfies the BST property for every node, otherwise false. Duplicate values are not allowed.
1 <= number of nodes <= 10^5-2^31 <= node value <= 2^31 - 1Input: {"tree":[5,1,4,null,null,3,6]}
Output: false
Node 4 sits in the right wing of 5 but holds a smaller value — the window check rejects it.
Input: {"tree":[2,1,3]}
Output: true
Every node stays inside the window its ancestors carved out.