Binary Search Tree Problems for Coding Interviews
23 Binary Search Tree problems from real coding interviews, each with test cases you can run online. By difficulty they split into 8 basic, 12 intermediate and 3 advanced. The companies that ask them most often are Amazon, Google, Meta, Microsoft.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Count Unique Binary Search Trees (Basic)
- BST Range Sum (Basic)
- BST Successor and Predecessor (Intermediate)
- Validate Binary Search Tree (Intermediate)
- Kth Smallest Value in a BST (Intermediate)
- Convert Sorted Array to BST (Basic)
- Mode Values in a BST (Intermediate)
- Minimum Absolute Difference in BST (Basic)
- Two Sum in a BST (Basic)
- Trim a BST (Intermediate)
- Insert Into a BST (Basic)
- Delete Node in a BST (Intermediate)
- Recover Swapped BST Values (Intermediate)
- Closest Value in a BST (Basic)
- BST From Preorder (Intermediate)
- Maximum Sum BST in Binary Tree (Advanced)
- Ways to Reorder Array to Get Same BST (Advanced)
- Convert Sorted List to BST (Intermediate)
- Increasing Order Search Tree (Basic)
- Convert BST to Greater Tree (Intermediate)
- Largest BST Subtree Size (Intermediate)
- Balance a Binary Search Tree (Intermediate)
- Optimal Binary Search Tree Cost (Advanced)
Related
- Basic Binary Search Tree problems
- Intermediate Binary Search Tree problems
- Practice coding problems online
- All interview guides
Frequently asked questions
How do I get good at binary search tree problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run binary search tree problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.