Given the root of a binary tree, determine whether it is a binary search tree by checking all structural and value constraints. Pattern focus: BST Validation with Bounds. A correct solution must validate every subtree with inherited bounds rather than checking only parent-child pairs.
root = binary tree root
true if the tree is a BST
Example 1:
Input:
root = [10,5,15,null,null,6,20]
Output:
false
Explanation:
Node 6 is in the right subtree of 10 but is smaller than 10.
Example 2:
Input:
root = [8,4,10,2,6,9,12]
Output:
true
Explanation:
All nodes satisfy the BST constraints.