Depth-First Search DSA Problems

314 depth-first search problems for coding interviews and campus placements, with hints and company tags. Below are the first 100 of 314: 39 easy, 0 medium and 61 hard. Practise them free on InternHack and track what you have solved.

Depth-First Search 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. Cousins in Binary Tree (Easy)
  10. Diameter of Binary Tree (Easy)
  11. Evaluate Boolean Binary Tree (Easy)
  12. Extract Kth Character From The Rope Tree (Easy)
  13. Find a Corresponding Node of a Binary Tree in a Clone of That Tree (Easy)
  14. Find All The Lonely Nodes (Easy)
  15. Find if Path Exists in Graph (Easy)
  16. Find Mode in Binary Search Tree (Easy)
  17. Flood Fill (Easy)
  18. Increasing Order Search Tree (Easy)
  19. Invert Binary Tree (Easy)
  20. Island Perimeter (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. Same Tree (Easy)
  33. Second Minimum Node In a Binary Tree (Easy)
  34. Subtree of Another Tree (Easy)
  35. Sum of Left Leaves (Easy)
  36. Sum of Root To Leaf Binary Numbers (Easy)
  37. Symmetric Tree (Easy)
  38. Two Sum IV - Input is a BST (Easy)
  39. Univalued Binary Tree (Easy)
  40. Alien Dictionary (Hard)
  41. Binary Tree Cameras (Hard)
  42. Binary Tree Maximum Path Sum (Hard)
  43. Check for Contradictions in Equations (Hard)
  44. Check if DFS Strings Are Palindromes (Hard)
  45. Check if the Rectangle Corner Is Reachable (Hard)
  46. Checking Existence of Edge Length Limited Paths II (Hard)
  47. Closest Binary Search Tree Value II (Hard)
  48. Closest Node to Path in Tree (Hard)
  49. Concatenated Words (Hard)
  50. Contain Virus (Hard)
  51. Count Paths That Can Form a Palindrome in a Tree (Hard)
  52. Count Valid Paths in a Tree (Hard)
  53. Count Ways to Build Rooms in an Ant Colony (Hard)
  54. Couples Holding Hands (Hard)
  55. Cracking the Safe (Hard)
  56. Create Components With Same Value (Hard)
  57. Critical Connections in a Network (Hard)
  58. Design Search Autocomplete System (Hard)
  59. Difference Between Maximum and Minimum Price Sum (Hard)
  60. Distance to a Cycle in Undirected Graph (Hard)
  61. Divide Nodes Into the Maximum Number of Groups (Hard)
  62. Escape a Large Maze (Hard)
  63. Find All People With Secret (Hard)
  64. Find Edges in Shortest Paths (Hard)
  65. Find Minimum Diameter After Merging Two Trees (Hard)
  66. Find Number of Coins to Place in Tree Nodes (Hard)
  67. Find the Last Marked Nodes in Tree (Hard)
  68. Find Weighted Median Node in Tree (Hard)
  69. Freedom Trail (Hard)
  70. Frog Position After T Seconds (Hard)
  71. Height of Binary Tree After Subtree Removal Queries (Hard)
  72. Kth Ancestor of a Tree Node (Hard)
  73. Last Day Where You Can Still Cross (Hard)
  74. Longest Cycle in a Graph (Hard)
  75. Longest Increasing Path in a Matrix (Hard)
  76. Longest Path With Different Adjacent Characters (Hard)
  77. Longest Special Path II (Hard)
  78. Making A Large Island (Hard)
  79. Maximize Sum of Weights after Edge Removals (Hard)
  80. Maximize the Number of Target Nodes After Connecting Trees II (Hard)
  81. Maximum Employees to Be Invited to a Meeting (Hard)
  82. Maximum Genetic Difference Query (Hard)
  83. Maximum Good Subtree Score (Hard)
  84. Maximum Number of K-Divisible Components (Hard)
  85. Maximum Partition Factor (Hard)
  86. Maximum Points After Collecting Coins From All Nodes (Hard)
  87. Maximum Profit from Trading Stocks with Discounts (Hard)
  88. Maximum Subgraph Score in a Tree (Hard)
  89. Maximum Sum BST in Binary Tree (Hard)
  90. Maximum XOR of Two Non-Overlapping Subtrees (Hard)
  91. Merge BSTs to Create Single BST (Hard)
  92. Minimize Malware Spread (Hard)
  93. Minimize Malware Spread II (Hard)
  94. Minimum Edge Reversals So Every Node Is Reachable (Hard)
  95. Minimum Flips in Binary Tree to Get Result (Hard)
  96. Minimum Number of Days to Disconnect Island (Hard)
  97. Minimum Runes to Add to Cast Spell (Hard)
  98. Minimum Score After Removals on a Tree (Hard)
  99. Minimum Time to Break Locks II (Hard)
  100. Move Sub-Tree of N-Ary Tree (Hard)

Companies that ask depth-first search 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