Loading problem…
Given the root of a binary tree, determine if it is a valid binary search tree (BST).
A valid BST is defined as follows:
Validate whether a binary tree satisfies the BST property. A common mistake is to only check parent-child relationships — you must ensure all ancestors are respected.
true if the tree is a valid BST, false otherwise// Tree: [2,1,3] → true (valid BST)
// Tree: [5,1,4,null,null,3,6] → false (4's left child 3 < 5's right child)