Microsoft Tree Coding Interview Questions
55 tree coding problems are tagged as asked at Microsoft in interviews and online assessments reported by candidates. By difficulty they split into 21 basic, 27 intermediate and 6 advanced. The topics they most often combine with are Binary Tree, Hash Table, Graph Theory, Binary Search Tree.
Reported questions change over time and are not a guarantee of what you will be asked, so use the list to see which patterns Microsoft tends to test. For each problem, practise explaining your approach, its time and space cost and the edge cases before you write the code; every problem opens in an editor that runs your code against test cases.
Coding problems
- Count Unique Binary Search Trees (Basic)
- Minimum Edge Reversals Per Node (Intermediate)
- Tree Nodes at Distance K (Advanced)
- Tree Diameter (Advanced)
- Tree Vertical Traversal (Intermediate)
- BST Range Sum (Basic)
- Find Duplicate Subtrees (Basic)
- Maximum Depth of Binary Tree (Basic)
- Symmetric Tree (Basic)
- Balanced Binary Tree (Basic)
- Validate Binary Search Tree (Intermediate)
- Kth Smallest Value in a BST (Intermediate)
- Binary Tree Maximum Path Sum (Advanced)
- Count Good Nodes in Binary Tree (Intermediate)
- Sum of Left Leaves (Basic)
- Binary Tree Right Side View (Intermediate)
- Largest Value in Each Tree Row (Basic)
- Zigzag Level Order Traversal (Intermediate)
- Binary Tree Inorder Traversal (Basic)
- Lowest Common Ancestor of Two Values (Intermediate)
- Subtree of Another Tree (Intermediate)
- Boundary of Binary Tree (Advanced)
- Same Tree (Basic)
- Invert Binary Tree (Basic)
- Binary Tree Preorder Traversal (Basic)
- Binary Tree Postorder Traversal (Basic)
- Level Order Traversal (Basic)
- Count Complete Tree Nodes (Intermediate)
- Tree From Inorder and Postorder (Intermediate)
- Delete Node in a BST (Intermediate)
- Maximum Width of Binary Tree (Intermediate)
- Cousins in Binary Tree (Basic)
- Leaf-Similar Trees (Basic)
- Most Frequent Subtree Sum (Intermediate)
- Bottom-Left Tree Value (Basic)
- Binary Tree Paths (Basic)
- Distribute Coins in Binary Tree (Intermediate)
- Flip Equivalent Binary Trees (Intermediate)
- Check Completeness of a Binary Tree (Intermediate)
- Minimum Depth of Binary Tree (Basic)
- Merge Two Binary Trees (Basic)
- Longest ZigZag Path in a Binary Tree (Intermediate)
- Sum of Root-to-Leaf Binary Numbers (Basic)
- Delete Leaves With a Given Value (Intermediate)
- Maximum Sum BST in Binary Tree (Advanced)
- Sum of Distances in Tree (Advanced)
- Graph Valid Tree (Intermediate)
- Redundant Connection (Intermediate)
- Implement Trie Operations (Intermediate)
- Flatten Binary Tree to Linked List (Intermediate)
- Convert BST to Greater Tree (Intermediate)
- Balance a Binary Search Tree (Intermediate)
- Minimum Fuel Cost to the Capital (Intermediate)
- Validate Binary Tree Nodes (Intermediate)
Related
- Microsoft coding interview questions
- Tree problems
- Microsoft basic problems
- Microsoft intermediate problems
- Microsoft advanced problems
- Company interview roadmaps
- All interview guides
Frequently asked questions
How should I use the Microsoft problem list?
Start with the basic problems, then the intermediate and advanced ones, and note which topics repeat. Solve each under a timer, then read the explanation.
Are these the exact Microsoft interview questions?
They are problems candidates reported being asked. Companies rotate questions, so use them to learn the patterns, not to predict the exact question.