# Tree DSA Problems

> 235 Tree coding problems for placements and interviews, sorted easiest first, with hints and company tags. Free practice on InternHack.

Canonical: https://www.internhack.in/learn/dsa/tree
Last updated: 2026-11-28

235 tree problems for coding interviews and campus placements, with hints and company tags. Below are the first 100 of 235: 41 easy, 9 medium and 50 hard. Practise them free on InternHack and track what you have solved.

## Tree problems, easiest first

1. [Average of Levels in Binary Tree](https://www.internhack.in/learn/dsa/problem/average-of-levels-in-binary-tree) (Easy)
2. [Balanced Binary Tree](https://www.internhack.in/learn/dsa/problem/balanced-binary-tree) (Easy)
3. [Binary Tree Inorder Traversal](https://www.internhack.in/learn/dsa/problem/binary-tree-inorder-traversal) (Easy)
4. [Binary Tree Paths](https://www.internhack.in/learn/dsa/problem/binary-tree-paths) (Easy)
5. [Binary Tree Postorder Traversal](https://www.internhack.in/learn/dsa/problem/binary-tree-postorder-traversal) (Easy)
6. [Binary Tree Preorder Traversal](https://www.internhack.in/learn/dsa/problem/binary-tree-preorder-traversal) (Easy)
7. [Binary Tree Tilt](https://www.internhack.in/learn/dsa/problem/binary-tree-tilt) (Easy)
8. [Closest Binary Search Tree Value](https://www.internhack.in/learn/dsa/problem/closest-binary-search-tree-value) (Easy)
9. [Convert Sorted Array to Binary Search Tree](https://www.internhack.in/learn/dsa/problem/convert-sorted-array-to-binary-search-tree) (Easy)
10. [Count Complete Tree Nodes](https://www.internhack.in/learn/dsa/problem/count-complete-tree-nodes) (Easy)
11. [Cousins in Binary Tree](https://www.internhack.in/learn/dsa/problem/cousins-in-binary-tree) (Easy)
12. [Diameter of Binary Tree](https://www.internhack.in/learn/dsa/problem/diameter-of-binary-tree) (Easy)
13. [Evaluate Boolean Binary Tree](https://www.internhack.in/learn/dsa/problem/evaluate-boolean-binary-tree) (Easy)
14. [Extract Kth Character From The Rope Tree](https://www.internhack.in/learn/dsa/problem/extract-kth-character-from-the-rope-tree) (Easy)
15. [Find a Corresponding Node of a Binary Tree in a Clone of That Tree](https://www.internhack.in/learn/dsa/problem/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree) (Easy)
16. [Find All The Lonely Nodes](https://www.internhack.in/learn/dsa/problem/find-all-the-lonely-nodes) (Easy)
17. [Find Mode in Binary Search Tree](https://www.internhack.in/learn/dsa/problem/find-mode-in-binary-search-tree) (Easy)
18. [Increasing Order Search Tree](https://www.internhack.in/learn/dsa/problem/increasing-order-search-tree) (Easy)
19. [Invert Binary Tree](https://www.internhack.in/learn/dsa/problem/invert-binary-tree) (Easy)
20. [Kth Largest Element in a Stream](https://www.internhack.in/learn/dsa/problem/kth-largest-element-in-a-stream) (Easy)
21. [Leaf-Similar Trees](https://www.internhack.in/learn/dsa/problem/leaf-similar-trees) (Easy)
22. [Maximum Depth of Binary Tree](https://www.internhack.in/learn/dsa/problem/maximum-depth-of-binary-tree) (Easy)
23. [Maximum Depth of N-ary Tree](https://www.internhack.in/learn/dsa/problem/maximum-depth-of-n-ary-tree) (Easy)
24. [Merge Two Binary Trees](https://www.internhack.in/learn/dsa/problem/merge-two-binary-trees) (Easy)
25. [Minimum Absolute Difference in BST](https://www.internhack.in/learn/dsa/problem/minimum-absolute-difference-in-bst) (Easy)
26. [Minimum Depth of Binary Tree](https://www.internhack.in/learn/dsa/problem/minimum-depth-of-binary-tree) (Easy)
27. [Minimum Distance Between BST Nodes](https://www.internhack.in/learn/dsa/problem/minimum-distance-between-bst-nodes) (Easy)
28. [N-ary Tree Postorder Traversal](https://www.internhack.in/learn/dsa/problem/n-ary-tree-postorder-traversal) (Easy)
29. [N-ary Tree Preorder Traversal](https://www.internhack.in/learn/dsa/problem/n-ary-tree-preorder-traversal) (Easy)
30. [Path Sum](https://www.internhack.in/learn/dsa/problem/path-sum) (Easy)
31. [Range Sum of BST](https://www.internhack.in/learn/dsa/problem/range-sum-of-bst) (Easy)
32. [Root Equals Sum of Children](https://www.internhack.in/learn/dsa/problem/root-equals-sum-of-children) (Easy)
33. [Same Tree](https://www.internhack.in/learn/dsa/problem/same-tree) (Easy)
34. [Search in a Binary Search Tree](https://www.internhack.in/learn/dsa/problem/search-in-a-binary-search-tree) (Easy)
35. [Second Minimum Node In a Binary Tree](https://www.internhack.in/learn/dsa/problem/second-minimum-node-in-a-binary-tree) (Easy)
36. [Subtree of Another Tree](https://www.internhack.in/learn/dsa/problem/subtree-of-another-tree) (Easy)
37. [Sum of Left Leaves](https://www.internhack.in/learn/dsa/problem/sum-of-left-leaves) (Easy)
38. [Sum of Root To Leaf Binary Numbers](https://www.internhack.in/learn/dsa/problem/sum-of-root-to-leaf-binary-numbers) (Easy)
39. [Symmetric Tree](https://www.internhack.in/learn/dsa/problem/symmetric-tree) (Easy)
40. [Two Sum IV - Input is a BST](https://www.internhack.in/learn/dsa/problem/two-sum-iv-input-is-a-bst) (Easy)
41. [Univalued Binary Tree](https://www.internhack.in/learn/dsa/problem/univalued-binary-tree) (Easy)
42. [Add One Row to Tree](https://www.internhack.in/learn/dsa/problem/add-one-row-to-tree) (Medium)
43. [All Elements in Two Binary Search Trees](https://www.internhack.in/learn/dsa/problem/all-elements-in-two-binary-search-trees) (Medium)
44. [All Nodes Distance K in Binary Tree](https://www.internhack.in/learn/dsa/problem/all-nodes-distance-k-in-binary-tree) (Medium)
45. [All Possible Full Binary Trees](https://www.internhack.in/learn/dsa/problem/all-possible-full-binary-trees) (Medium)
46. [Amount of Time for Binary Tree to Be Infected](https://www.internhack.in/learn/dsa/problem/amount-of-time-for-binary-tree-to-be-infected) (Medium)
47. [Balance a Binary Search Tree](https://www.internhack.in/learn/dsa/problem/balance-a-binary-search-tree) (Medium)
48. [Binary Search Tree Iterator](https://www.internhack.in/learn/dsa/problem/binary-search-tree-iterator) (Medium)
49. [Binary Search Tree Iterator II](https://www.internhack.in/learn/dsa/problem/binary-search-tree-iterator-ii) (Medium)
50. [Binary Search Tree to Greater Sum Tree](https://www.internhack.in/learn/dsa/problem/binary-search-tree-to-greater-sum-tree) (Medium)
51. [Binary Tree Cameras](https://www.internhack.in/learn/dsa/problem/binary-tree-cameras) (Hard)
52. [Binary Tree Maximum Path Sum](https://www.internhack.in/learn/dsa/problem/binary-tree-maximum-path-sum) (Hard)
53. [Build Binary Expression Tree From Infix Expression](https://www.internhack.in/learn/dsa/problem/build-binary-expression-tree-from-infix-expression) (Hard)
54. [Check if DFS Strings Are Palindromes](https://www.internhack.in/learn/dsa/problem/check-if-dfs-strings-are-palindromes) (Hard)
55. [Closest Binary Search Tree Value II](https://www.internhack.in/learn/dsa/problem/closest-binary-search-tree-value-ii) (Hard)
56. [Closest Node to Path in Tree](https://www.internhack.in/learn/dsa/problem/closest-node-to-path-in-tree) (Hard)
57. [Collect Coins in a Tree](https://www.internhack.in/learn/dsa/problem/collect-coins-in-a-tree) (Hard)
58. [Count Paths That Can Form a Palindrome in a Tree](https://www.internhack.in/learn/dsa/problem/count-paths-that-can-form-a-palindrome-in-a-tree) (Hard)
59. [Count Valid Paths in a Tree](https://www.internhack.in/learn/dsa/problem/count-valid-paths-in-a-tree) (Hard)
60. [Count Ways to Build Rooms in an Ant Colony](https://www.internhack.in/learn/dsa/problem/count-ways-to-build-rooms-in-an-ant-colony) (Hard)
61. [Create Components With Same Value](https://www.internhack.in/learn/dsa/problem/create-components-with-same-value) (Hard)
62. [Cycle Length Queries in a Tree](https://www.internhack.in/learn/dsa/problem/cycle-length-queries-in-a-tree) (Hard)
63. [Difference Between Maximum and Minimum Price Sum](https://www.internhack.in/learn/dsa/problem/difference-between-maximum-and-minimum-price-sum) (Hard)
64. [Find Minimum Diameter After Merging Two Trees](https://www.internhack.in/learn/dsa/problem/find-minimum-diameter-after-merging-two-trees) (Hard)
65. [Find Number of Coins to Place in Tree Nodes](https://www.internhack.in/learn/dsa/problem/find-number-of-coins-to-place-in-tree-nodes) (Hard)
66. [Find the Last Marked Nodes in Tree](https://www.internhack.in/learn/dsa/problem/find-the-last-marked-nodes-in-tree) (Hard)
67. [Find the Maximum Sum of Node Values](https://www.internhack.in/learn/dsa/problem/find-the-maximum-sum-of-node-values) (Hard)
68. [Find Weighted Median Node in Tree](https://www.internhack.in/learn/dsa/problem/find-weighted-median-node-in-tree) (Hard)
69. [Frog Position After T Seconds](https://www.internhack.in/learn/dsa/problem/frog-position-after-t-seconds) (Hard)
70. [Height of Binary Tree After Subtree Removal Queries](https://www.internhack.in/learn/dsa/problem/height-of-binary-tree-after-subtree-removal-queries) (Hard)
71. [Kth Ancestor of a Tree Node](https://www.internhack.in/learn/dsa/problem/kth-ancestor-of-a-tree-node) (Hard)
72. [Longest Path With Different Adjacent Characters](https://www.internhack.in/learn/dsa/problem/longest-path-with-different-adjacent-characters) (Hard)
73. [Longest Special Path II](https://www.internhack.in/learn/dsa/problem/longest-special-path-ii) (Hard)
74. [Maximize Sum of Weights after Edge Removals](https://www.internhack.in/learn/dsa/problem/maximize-sum-of-weights-after-edge-removals) (Hard)
75. [Maximize the Number of Target Nodes After Connecting Trees II](https://www.internhack.in/learn/dsa/problem/maximize-the-number-of-target-nodes-after-connecting-trees-ii) (Hard)
76. [Maximum Good Subtree Score](https://www.internhack.in/learn/dsa/problem/maximum-good-subtree-score) (Hard)
77. [Maximum Number of K-Divisible Components](https://www.internhack.in/learn/dsa/problem/maximum-number-of-k-divisible-components) (Hard)
78. [Maximum Points After Collecting Coins From All Nodes](https://www.internhack.in/learn/dsa/problem/maximum-points-after-collecting-coins-from-all-nodes) (Hard)
79. [Maximum Profit from Trading Stocks with Discounts](https://www.internhack.in/learn/dsa/problem/maximum-profit-from-trading-stocks-with-discounts) (Hard)
80. [Maximum Subgraph Score in a Tree](https://www.internhack.in/learn/dsa/problem/maximum-subgraph-score-in-a-tree) (Hard)
81. [Maximum Sum BST in Binary Tree](https://www.internhack.in/learn/dsa/problem/maximum-sum-bst-in-binary-tree) (Hard)
82. [Maximum XOR of Two Non-Overlapping Subtrees](https://www.internhack.in/learn/dsa/problem/maximum-xor-of-two-non-overlapping-subtrees) (Hard)
83. [Merge BSTs to Create Single BST](https://www.internhack.in/learn/dsa/problem/merge-bsts-to-create-single-bst) (Hard)
84. [Minimum Edge Weight Equilibrium Queries in a Tree](https://www.internhack.in/learn/dsa/problem/minimum-edge-weight-equilibrium-queries-in-a-tree) (Hard)
85. [Minimum Flips in Binary Tree to Get Result](https://www.internhack.in/learn/dsa/problem/minimum-flips-in-binary-tree-to-get-result) (Hard)
86. [Minimum Score After Removals on a Tree](https://www.internhack.in/learn/dsa/problem/minimum-score-after-removals-on-a-tree) (Hard)
87. [Move Sub-Tree of N-Ary Tree](https://www.internhack.in/learn/dsa/problem/move-sub-tree-of-n-ary-tree) (Hard)
88. [Number of Good Paths](https://www.internhack.in/learn/dsa/problem/number-of-good-paths) (Hard)
89. [Number Of Ways To Reconstruct A Tree](https://www.internhack.in/learn/dsa/problem/number-of-ways-to-reconstruct-a-tree) (Hard)
90. [Number of Ways to Reorder Array to Get Same BST](https://www.internhack.in/learn/dsa/problem/number-of-ways-to-reorder-array-to-get-same-bst) (Hard)
91. [Recover a Tree From Preorder Traversal](https://www.internhack.in/learn/dsa/problem/recover-a-tree-from-preorder-traversal) (Hard)
92. [Serialize and Deserialize Binary Tree](https://www.internhack.in/learn/dsa/problem/serialize-and-deserialize-binary-tree) (Hard)
93. [Serialize and Deserialize N-ary Tree](https://www.internhack.in/learn/dsa/problem/serialize-and-deserialize-n-ary-tree) (Hard)
94. [Shortest Path in a Weighted Tree](https://www.internhack.in/learn/dsa/problem/shortest-path-in-a-weighted-tree) (Hard)
95. [Subtree Removal Game with Fibonacci Tree](https://www.internhack.in/learn/dsa/problem/subtree-removal-game-with-fibonacci-tree) (Hard)
96. [Sum of Distances in Tree](https://www.internhack.in/learn/dsa/problem/sum-of-distances-in-tree) (Hard)
97. [Sum of Perfect Square Ancestors](https://www.internhack.in/learn/dsa/problem/sum-of-perfect-square-ancestors) (Hard)
98. [Total Sum of Interaction Cost in Tree Groups](https://www.internhack.in/learn/dsa/problem/total-sum-of-interaction-cost-in-tree-groups) (Hard)
99. [Tree of Coprimes](https://www.internhack.in/learn/dsa/problem/tree-of-coprimes) (Hard)
100. [Vertical Order Traversal of a Binary Tree](https://www.internhack.in/learn/dsa/problem/vertical-order-traversal-of-a-binary-tree) (Hard)

## Companies that ask tree problems

- [Google](https://www.internhack.in/learn/dsa/companies/google): 74 of these problems
- [Amazon](https://www.internhack.in/learn/dsa/companies/amazon): 63 of these problems
- [Meta](https://www.internhack.in/learn/dsa/companies/meta): 50 of these problems
- [Microsoft](https://www.internhack.in/learn/dsa/companies/microsoft): 48 of these problems
- [Bloomberg](https://www.internhack.in/learn/dsa/companies/bloomberg): 41 of these problems
- [Oracle](https://www.internhack.in/learn/dsa/companies/oracle): 13 of these problems
- [Apple](https://www.internhack.in/learn/dsa/companies/apple): 12 of these problems
- [Uber](https://www.internhack.in/learn/dsa/companies/uber): 12 of these problems
- [Adobe](https://www.internhack.in/learn/dsa/companies/adobe): 11 of these problems
- [Linkedin](https://www.internhack.in/learn/dsa/companies/linkedin): 11 of these problems
- [Tiktok](https://www.internhack.in/learn/dsa/companies/tiktok): 10 of these problems
- [Salesforce](https://www.internhack.in/learn/dsa/companies/salesforce): 7 of these problems

## Before your interview

Most resumes are filtered by software before a recruiter reads them. [Check your resume ATS score free](https://www.internhack.in/ats-score/try), no signup needed.

## Other DSA topics

- [Array](https://www.internhack.in/learn/dsa/array) (1869)
- [String](https://www.internhack.in/learn/dsa/string) (775)
- [Hash Table](https://www.internhack.in/learn/dsa/hash-table) (708)
- [Math](https://www.internhack.in/learn/dsa/math) (564)
- [Dynamic Programming](https://www.internhack.in/learn/dsa/dynamic-programming) (557)
- [Sorting](https://www.internhack.in/learn/dsa/sorting) (464)
- [Greedy](https://www.internhack.in/learn/dsa/greedy) (407)
- [Depth-First Search](https://www.internhack.in/learn/dsa/depth-first-search) (314)
- [Binary Search](https://www.internhack.in/learn/dsa/binary-search) (298)
- [Matrix](https://www.internhack.in/learn/dsa/matrix) (246)
- [Breadth-First Search](https://www.internhack.in/learn/dsa/breadth-first-search) (245)
- [Bit Manipulation](https://www.internhack.in/learn/dsa/bit-manipulation) (238)
- [Two Pointers](https://www.internhack.in/learn/dsa/two-pointers) (217)
- [Prefix Sum](https://www.internhack.in/learn/dsa/prefix-sum) (204)
- [Database](https://www.internhack.in/learn/dsa/database) (197)
- [Heap (Priority Queue)](https://www.internhack.in/learn/dsa/heap-priority-queue) (196)
- [Simulation](https://www.internhack.in/learn/dsa/simulation) (177)
- [Counting](https://www.internhack.in/learn/dsa/counting) (174)
- [Binary Tree](https://www.internhack.in/learn/dsa/binary-tree) (169)
- [Stack](https://www.internhack.in/learn/dsa/stack) (167)

## Related

- [Home](https://www.internhack.in/)
- [Learn](https://www.internhack.in/learn)
- [DSA](https://www.internhack.in/learn/dsa)
