Given a binary tree, figure out whether it’s a valid binary search tree.

In a BST, each node’s key value is smaller than the key value of the right subtree nodes and greater than the key values of the left subtree nodes.


The following binary tree is an example of a valid BST:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.