Recursion

Validate BST

Binary Search Tree

Given the root of a tree root, return whether the tree is a BST or not. The values in the tree are all unique.

Example 1:

=> returns True\notag \texttt{=> returns True}

Example 2:

=> returns False\notag \texttt{=> returns False}

Explanation 2: The tree is not a BST because when you move left, you get a larger value. You should instead get a smaller value.

First Few Test Cases:

There are 2 ways you can solve this problem.

Using an inorder traversal:

Using simple recursion:

Mark as Completed:
Submits:
isBinarySearchTree
Imports:
TreeNode
Test your code to get an output here!
isBinarySearchTree(
)
Test your code to get an output here!