98. Validate Binary Search Tree
Practice Validate Binary Search Tree for free on NudgeCode: Medium, Binary Tree pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Decide whether a binary tree is a valid binary search tree. In a valid BST, every value in a node's left subtree is strictly smaller than the node's value, every value in its right subtree is strictly larger, and both subtrees are valid BSTs themselves. Equal values are not allowed.
Example
root = [5,1,4,null,null,3,6] -> false (3 is in the right subtree of 5)
Constraints
- 1 <= number of nodes <= 10^4
- -2^31 <= Node.val <= 2^31 - 1