Algorithm · C3.ai · Medium
You are handed the root node of a binary tree. Determine whether the tree is a valid binary search tree, returning true if it is and false otherwise. A tree counts as a valid binary search tree when, for every node, each value in its left subtree is strictly less than the node's own value, each value in its right subtree is strictly greater than the node's own value, and both of those subtrees are themselves valid binary search trees under the same rules. Examples Example 1…