MEDIUMasked at 1 company

All Paths From Source to Target

A medium-tier problem at 83% community acceptance, tagged with Backtracking, Depth-First Search, Breadth-First Search. Reported in interviews at Bloomberg and 0 others.

Founder's read

All Paths From Source to Target is a medium-difficulty graph problem with an 83% acceptance rate, but don't let that fool you. It's asked at Bloomberg and similar firms testing backtracking fundamentals. The trap is overthinking it: you're not finding the shortest path or optimizing anything. You need to enumerate every single path from node 0 to node n-1 in a directed acyclic graph and return them all. If you freeze on the recursive structure or forget to backtrack correctly, you'll waste 20 minutes rewriting. StealthCoder solves this invisibly during your OA if the pattern doesn't click immediately.

Companies asking
1
Difficulty
MEDIUM
Acceptance
83%

Companies that ask "All Paths From Source to Target"

If this hits your live OA

All Paths From Source to Target is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.

Get StealthCoder
What this means

The core trick is recognizing this as a pure backtracking problem, not a shortest-path one. You do a depth-first search from the source, build each path as a list, and when you hit the target node, add a copy of that path to your results. The critical detail: you must backtrack by removing the last node before returning from recursion, so other branches don't inherit nodes from sibling paths. Most candidates either forget the backtrack step or try to clone the list improperly. The graph is given as an adjacency list, so iteration is straightforward. BFS works too but DFS is cleaner here because you're collecting complete paths, not layers. This problem tests whether you truly understand backtracking mechanics, which Bloomberg values in systems interviews.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

All Paths From Source to Target recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. 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.

All Paths From Source to Target interview FAQ

Is this actually an easy problem mislabeled medium?+

No. The 83% acceptance rate reflects that many candidates have memorized the backtracking template. The problem itself requires clean recursive thinking and proper list manipulation. Missing the backtrack step or cloning the list wrong will fail test cases silently.

Why is backtracking necessary here?+

Without backtracking, when you explore one branch, nodes from that path stay in your current list. The next branch then inherits those nodes, corrupting its path. Backtracking removes the node after recursion returns, ensuring each branch starts fresh from its parent.

Should I use DFS or BFS?+

DFS is simpler because you naturally build complete paths as you traverse. BFS works but requires queue management and is harder to collect full paths correctly. For enumeration problems like this, DFS and backtracking are the standard choice.

How does this relate to other graph problems?+

It's foundational for backtracking on graphs. You'll see the same pattern in Word Ladder, N-Queens, and Permutations. Mastering the backtrack-and-restore cycle here transfers directly to harder problems.

Why does Bloomberg ask this?+

It's a quick filter for backtracking literacy. Systems engineers need to enumerate states and explore search spaces. If you can't code clean backtracking under time pressure, that's a red flag for more complex algorithm work.

Want the actual problem statement? View "All Paths From Source to Target" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.