Skip to content

Interview question · Trees

Validate Binary Search Tree

Validate Binary Search Tree is a Medium question that uses the trees pattern. PrepKit files it under Trees.

PrepKit lists the title and a link. The problem statement stays on the original site.

Checking your saved items

Copyright and correction requests

Source content: English

Key facts

Topic
Trees
Pattern
trees
Difficulty
Medium
Appears in
Grind 75
Website
leetcode.com
License
MIT License

How to use it

  1. Read the problem on the original site.
  2. Try it on your own before you look at hints or solutions.
  3. Then work through a related question with the same pattern.

About the Trees pattern

PrepKit study notes. PrepKit editors wrote these as general advice. They are not taken from the problem or from any published solution.

What it is
Problems on nodes that have children, most often binary trees and binary search trees, solved with depth-first or breadth-first traversal.
How to recognize it
The input is a root node, or the answer depends on depth, paths, ancestors, subtrees or the sorted order of the nodes.
Common pitfalls
Forgetting the null-child base case, mixing up what a recursive call returns with what it updates, and assuming any binary tree is a balanced search tree.

Related preparation

These are PrepKit study suggestions, not employer endorsements or predictions of interview questions.

Pages that include this

Common questions

Where can I practice Validate Binary Search Tree?

Open it on leetcode.com. PrepKit links there and does not copy the problem.

What pattern does Validate Binary Search Tree use?

PrepKit files it under trees, at Medium difficulty.

Source and license

Source and license

License:
MIT License
Author:
Yangshun Tay
Source version:
e1d28e8
Last checked against the source:
Changes:
PrepKit kept only Grind 75 question titles, difficulty, topic, and LeetCode links. The weekly schedule, durations, and ordering are not copied, and no LeetCode problem text is stored.
Visit original source
Full license and copyright notice

MIT License Copyright (c) 2017-Present Yangshun Tay Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.