Depth-First Search interview questions
200 depth-first search problems tagged across recent interview reports. Drilled most heavily by linkedin, meta, and doordash.
Depth-First Search is the foundational graph and tree traversal pattern that powers 200+ interview problems. It's the backbone of connectivity questions, pathfinding, and tree manipulation, the kind of problem that appears across every major tech company assessment. LinkedIn, Meta, and DoorDash lean on DFS variants constantly. If you can't recognize and code DFS cold under pressure, you'll stall on live assessments. StealthCoder is the invisible safety net for the DFS variant that breaks your instinct during the real OA.
Most-asked depth-first search problems
Showing top 50 of 200 depth-first search problems by # companies asking.
You can't drill every depth-first search variant before the assessment. StealthCoder runs invisibly during screen share and solves whichever variant they throw at you. No browser extension. No detection signature. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderDFS problems fall into three buckets: graph connectivity (accounts-merge, all-ancestors-of-a-node-in-a-directed-acyclic-graph), tree traversal (balanced-binary-tree, binary-tree-inorder-traversal), and path-finding (all-paths-from-source-to-target). Recognize DFS by the need to explore every branch from a node before backtracking, either recursively via the call stack or iteratively with an explicit stack. Common subtypes include implicit graphs (grid-based like battleships-in-a-board), DAG problems, and tree annotation (binary-search-tree-to-greater-sum-tree). Start with tree DFS, move to grid and graph problems, then tackle the harder constraint variants. When you hit a hard DFS mutation in your live interview, especially under time pressure, StealthCoder reads the problem and delivers a working solution in seconds.
Companies that hire most on depth-first search
200 depth-first search problems.
You won't drill them all. Pass anyway.
Depth-First Search is one of the patterns interviews actually filter on. Memorizing every variant in a week is a fantasy. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds, no matter which depth-first search flavor lands in your live OA. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Depth-First Search interview FAQ
How many DFS problems should I drill before my OA?+
With 200 problems in this pattern, focus on the first 30 to 40 problems covering trees and grids. Practice recursive and iterative versions. Then drill 10 to 15 harder variants from your target company's list. Most candidates underestimate DFS subtlety; one hard problem during the real OA will break you if you haven't seen the pattern type.
Is DFS tested more heavily at certain companies?+
Yes. LinkedIn (76 problems), Meta (68), and DoorDash (60) weight DFS heavily in their assessments. If you're interviewing there, DFS fluency isn't optional, it's the minimum bar. Apple (38), Amazon (42), and Google (45) test it consistently, but breadth is also required.
How do I recognize a DFS problem in the wild?+
Look for explicit or implicit graphs, trees, or grids where you need to explore exhaustively. Keywords: 'all paths', 'connected components', 'reach', 'ancestors', 'traverse', 'merge', 'find all'. If the problem asks 'visit every node' or 'is X reachable from Y', DFS is likely the core pattern.
What's the difference between DFS and BFS in interviews?+
DFS uses a stack (recursion or explicit); BFS uses a queue. DFS is simpler to code and goes deep first, better for pathfinding, connectivity, and backtracking. BFS finds shortest paths in unweighted graphs. For most interview problems, DFS is the default unless the problem explicitly asks for 'shortest' or 'closest'.
Should I memorize the DFS template?+
Yes. A clean recursive DFS template, base case, mark visited, iterate neighbors, recurse, takes 15 seconds to write and removes cognitive load during the interview. Practice it until you can code it with your eyes closed. That mental space matters when a variant lands and you need to adapt.