Skip to main content
All Questions

Determine if a given binary tree is a binary search tree (BST).

Medium

Determine if a given binary tree is a valid Binary Search Tree (BST).

Examples

All trees defined in level-order root = [5, 2, 6] output: true root = [5, 2, 4, null, null, 3, 6] output: false root = [] output: true

In these examples, the output is true if the given binary tree root is a valid BST, and false otherwise.

Related courses

Course

Machine Learning Engineer Interview Prep

Land your dream machine learning role at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Explore ML system design, core concepts, coding, behavioral interviews, and more.

Course

Data Science Interview Prep

Land your dream data science role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Practice statistics, experimentation, coding, SQL, machine learning, behavioral interviews, and more.