Back to course home
0% completed
Solution: Validate Binary Search Tree
Problem Statement
Determine if a given binary tree is a binary search tree (BST). In a BST, for each node:
- All nodes to its left have values less than the node's value.
- All nodes to its right have values greater than the node's value.
Examples
Example 1:
- Input: [5,3,7]
- Expected Output: true
- Justification: The left child of the root (3) is less than the root, and the right child of the root (7) is greater than the root. Hence, it's a BST.
Example 2:
- Input: [5,7,3]
- Expected Output: false
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible