Tree DSA Problems

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 (Easy)
  2. Balanced Binary Tree (Easy)
  3. Binary Tree Inorder Traversal (Easy)
  4. Binary Tree Paths (Easy)
  5. Binary Tree Postorder Traversal (Easy)
  6. Binary Tree Preorder Traversal (Easy)
  7. Binary Tree Tilt (Easy)
  8. Closest Binary Search Tree Value (Easy)
  9. Convert Sorted Array to Binary Search Tree (Easy)
  10. Count Complete Tree Nodes (Easy)
  11. Cousins in Binary Tree (Easy)
  12. Diameter of Binary Tree (Easy)
  13. Evaluate Boolean Binary Tree (Easy)
  14. Extract Kth Character From The Rope Tree (Easy)
  15. Find a Corresponding Node of a Binary Tree in a Clone of That Tree (Easy)
  16. Find All The Lonely Nodes (Easy)
  17. Find Mode in Binary Search Tree (Easy)
  18. Increasing Order Search Tree (Easy)
  19. Invert Binary Tree (Easy)
  20. Kth Largest Element in a Stream (Easy)
  21. Leaf-Similar Trees (Easy)
  22. Maximum Depth of Binary Tree (Easy)
  23. Maximum Depth of N-ary Tree (Easy)
  24. Merge Two Binary Trees (Easy)
  25. Minimum Absolute Difference in BST (Easy)
  26. Minimum Depth of Binary Tree (Easy)
  27. Minimum Distance Between BST Nodes (Easy)
  28. N-ary Tree Postorder Traversal (Easy)
  29. N-ary Tree Preorder Traversal (Easy)
  30. Path Sum (Easy)
  31. Range Sum of BST (Easy)
  32. Root Equals Sum of Children (Easy)
  33. Same Tree (Easy)
  34. Search in a Binary Search Tree (Easy)
  35. Second Minimum Node In a Binary Tree (Easy)
  36. Subtree of Another Tree (Easy)
  37. Sum of Left Leaves (Easy)
  38. Sum of Root To Leaf Binary Numbers (Easy)
  39. Symmetric Tree (Easy)
  40. Two Sum IV - Input is a BST (Easy)
  41. Univalued Binary Tree (Easy)
  42. Add One Row to Tree (Medium)
  43. All Elements in Two Binary Search Trees (Medium)
  44. All Nodes Distance K in Binary Tree (Medium)
  45. All Possible Full Binary Trees (Medium)
  46. Amount of Time for Binary Tree to Be Infected (Medium)
  47. Balance a Binary Search Tree (Medium)
  48. Binary Search Tree Iterator (Medium)
  49. Binary Search Tree Iterator II (Medium)
  50. Binary Search Tree to Greater Sum Tree (Medium)
  51. Binary Tree Cameras (Hard)
  52. Binary Tree Maximum Path Sum (Hard)
  53. Build Binary Expression Tree From Infix Expression (Hard)
  54. Check if DFS Strings Are Palindromes (Hard)
  55. Closest Binary Search Tree Value II (Hard)
  56. Closest Node to Path in Tree (Hard)
  57. Collect Coins in a Tree (Hard)
  58. Count Paths That Can Form a Palindrome in a Tree (Hard)
  59. Count Valid Paths in a Tree (Hard)
  60. Count Ways to Build Rooms in an Ant Colony (Hard)
  61. Create Components With Same Value (Hard)
  62. Cycle Length Queries in a Tree (Hard)
  63. Difference Between Maximum and Minimum Price Sum (Hard)
  64. Find Minimum Diameter After Merging Two Trees (Hard)
  65. Find Number of Coins to Place in Tree Nodes (Hard)
  66. Find the Last Marked Nodes in Tree (Hard)
  67. Find the Maximum Sum of Node Values (Hard)
  68. Find Weighted Median Node in Tree (Hard)
  69. Frog Position After T Seconds (Hard)
  70. Height of Binary Tree After Subtree Removal Queries (Hard)
  71. Kth Ancestor of a Tree Node (Hard)
  72. Longest Path With Different Adjacent Characters (Hard)
  73. Longest Special Path II (Hard)
  74. Maximize Sum of Weights after Edge Removals (Hard)
  75. Maximize the Number of Target Nodes After Connecting Trees II (Hard)
  76. Maximum Good Subtree Score (Hard)
  77. Maximum Number of K-Divisible Components (Hard)
  78. Maximum Points After Collecting Coins From All Nodes (Hard)
  79. Maximum Profit from Trading Stocks with Discounts (Hard)
  80. Maximum Subgraph Score in a Tree (Hard)
  81. Maximum Sum BST in Binary Tree (Hard)
  82. Maximum XOR of Two Non-Overlapping Subtrees (Hard)
  83. Merge BSTs to Create Single BST (Hard)
  84. Minimum Edge Weight Equilibrium Queries in a Tree (Hard)
  85. Minimum Flips in Binary Tree to Get Result (Hard)
  86. Minimum Score After Removals on a Tree (Hard)
  87. Move Sub-Tree of N-Ary Tree (Hard)
  88. Number of Good Paths (Hard)
  89. Number Of Ways To Reconstruct A Tree (Hard)
  90. Number of Ways to Reorder Array to Get Same BST (Hard)
  91. Recover a Tree From Preorder Traversal (Hard)
  92. Serialize and Deserialize Binary Tree (Hard)
  93. Serialize and Deserialize N-ary Tree (Hard)
  94. Shortest Path in a Weighted Tree (Hard)
  95. Subtree Removal Game with Fibonacci Tree (Hard)
  96. Sum of Distances in Tree (Hard)
  97. Sum of Perfect Square Ancestors (Hard)
  98. Total Sum of Interaction Cost in Tree Groups (Hard)
  99. Tree of Coprimes (Hard)
  100. Vertical Order Traversal of a Binary Tree (Hard)

Companies that ask tree problems

Before your interview

Most resumes are filtered by software before a recruiter reads them. Check your resume ATS score free, no signup needed.

Other DSA topics