Given the root of a binary tree, determine if it is a valid binary search tree (BST).
A valid BST is defined as follows:
The tree is given as a level-order array where null represents missing nodes. For example, [2, 1, 3] represents:
2
/ \
1 3
root = [2, 1, 3]trueroot = [5, 1, 4, null, null, 3, 6]falseroot = [1]trueThe number of nodes in the tree is in the range [0, 10^4]-2^31 <= Node.val <= 2^31 - 1Expected time complexity: O(n)Run your code to see results
Use Cmd+Enter to run