Intermediate Binary Tree Problems for Coding Interviews
40 intermediate Binary Tree problems from real coding interviews, each with test cases you can run online. By difficulty they split into 0 basic, 40 intermediate and 0 advanced. The companies that ask them most often are Google, Amazon, 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
- Lowest Common Ancestor With Parent Pointers (Intermediate)
- Tree Infection Time (Intermediate)
- BST Successor and Predecessor (Intermediate)
- Validate Binary Search Tree (Intermediate)
- Kth Smallest Value in a BST (Intermediate)
- Count Good Nodes in Binary Tree (Intermediate)
- Binary Tree Right Side View (Intermediate)
- Tree From Preorder and Inorder (Intermediate)
- Tree From Inorder and Postorder (Intermediate)
- Mode Values in a BST (Intermediate)
- Trim a BST (Intermediate)
- Delete Node in a BST (Intermediate)
- Recover Swapped BST Values (Intermediate)
- Maximum Width of Binary Tree (Intermediate)
- Distribute Coins in Binary Tree (Intermediate)
- Flip Equivalent Binary Trees (Intermediate)
- Check Completeness of a Binary Tree (Intermediate)
- Longest ZigZag Path in a Binary Tree (Intermediate)
- Maximum Product of Split Binary Tree (Intermediate)
- Binary Tree Coloring Game (Intermediate)
- Find Leaves of Binary Tree (Intermediate)
- BST From Preorder (Intermediate)
- Count Full Binary Trees (Intermediate)
- Convert Sorted List to BST (Intermediate)
- Linked List in Binary Tree (Intermediate)
- Flatten Binary Tree to Linked List (Intermediate)
- Construct Maximum Binary Tree (Intermediate)
- Binary Tree Upside Down (Intermediate)
- Convert BST to Greater Tree (Intermediate)
- Largest BST Subtree Size (Intermediate)
- Diagonal Traversal of Binary Tree (Intermediate)
- Top View of Binary Tree (Intermediate)
- Bottom View of Binary Tree (Intermediate)
- Check if Binary Tree Is a Heap (Intermediate)
- Balance a Binary Search Tree (Intermediate)
- Create Binary Tree From Descriptions (Intermediate)
- Cousins in Binary Tree II (Intermediate)
- Count Nodes With the Highest Score (Intermediate)
- Validate Binary Tree Nodes (Intermediate)
- Minimum Cost Tree From Leaf Values (Intermediate)
Related
Frequently asked questions
How do I get good at binary 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 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.