...

/

Is a Binary Search Tree Valid?

Is a Binary Search Tree Valid?

Given a binary tree, determine whether it's a valid binary search tree.

Statement

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.

Example

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

Access this course and 1400+ top-rated courses and projects.