Challenge: Is It a BST?

Let’s determine if a binary tree is a BST or not.

Problem

Find out if a given binary tree is a BST.

Input

A BST.

Output

Return true if the tree is a BST, false otherwise.

Sample input

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