Given the root of a binary tree, return true if it is a valid binary search tree (BST), and false if it isn't.
In a BST, every node splits the values below it in two:
- everything below it on the left side, at any depth, is smaller than the node
- everything below it on the right side, at any depth, is bigger than the node
Checking a node against only its own children isn't enough: the rule covers the whole side. Equal values break the rule, wherever they are. An empty tree and a single node are both valid. Values are integers as small as -2^31 and as big as 2^31 - 1. The tree has up to 10,000 nodes.
Input: root = [5, 3, 8, null, null, 4, 9]
Output: false4 is a correct left child of 8. But 4 is in the right subtree of 5, and it is smaller than 5.
Input: root = [5, 3, 8, 1, 4, 7, 9]
Output: true
Input: root = [2, 2, 3]
Output: falseEqual values break the strict ordering.