Reported April 2026
Citadeldepth first search

Minimum Path Sum to Target in Binary Tree

Reported by candidates from Citadel's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Citadel OA. Under 2s to a working solution.
Founder's read

Citadel asked this in April 2026: find a root-to-leaf path in a binary tree that sums to a target, then return the lexicographically smallest one if multiple exist. You've got a DFS problem wrapped in a path-reconstruction layer. The trick is that you need to track the cumulative sum while traversing, collect all valid paths, then sort and return the smallest. StealthCoder can spot the DFS structure and remind you of the comparison logic if you freeze mid-interview.

The problem

You are given a binary tree and an integer targetSum. A valid path is a root-to-leaf path whose node values add up to targetSum. Among all valid paths, return the minimum one using the following tie-breaking rules: If no valid path exists, return an empty array. Function Description Complete the function findMinimumTargetPath in the editor below. findMinimumTargetPath has the following parameters: Returns The path 5 -> 4 -> 11 -> 2 sums to 22 and is the selected valid path. No root-to-leaf path sums to 5, so the answer is empty.

Reported by candidates. Source: FastPrep

Pattern and pitfall

This is depth-first search with backtracking and lexicographic comparison. You traverse from root to leaf, maintaining a running sum. When you hit a leaf and the sum matches the target, you save that path. The catch: you must compare paths lexicographically to pick the smallest one. Many candidates forget the comparison step or implement it wrong. The pattern is classic DFS with path tracking, but the post-processing (sorting or comparing paths as you go) is where the bug lives. If you blank on the comparison logic during the OA, StealthCoder gives you the exact ordering rule so you don't guess.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Minimum Path Sum to Target in Binary Tree cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as path sum ii. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Citadel's OA.

Citadel reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Path Sum to Target in Binary Tree FAQ

What does 'lexicographically smallest' mean for paths here?+

Compare the paths element-by-element from left to right. The path with the smaller first differing value wins. If one path is a prefix of another, the shorter one is smaller. It's string comparison logic applied to integer sequences.

Do I need to find all valid paths or stop at the first one?+

You must find all valid paths that sum to targetSum, then return the lexicographically smallest. Stopping early breaks the solution. DFS collects them all, then you sort or compare to pick the winner.

How do I handle the tree structure in the code?+

Standard DFS recursion: if node is null, return or skip. If node is a leaf and current sum equals targetSum, save the path. Otherwise, recurse on left and right children with updated sum. Use a list to track the current path as you go.

What's the most common mistake on this problem?+

Forgetting to implement the lexicographic comparison correctly, or stopping at the first valid path instead of collecting all of them. Also, not properly handling the leaf-node check (a leaf has no children, not just null value).

Can I solve this iteratively or must it be recursive?+

DFS with recursion is cleaner here because you naturally maintain the path stack. You can do it iteratively with an explicit stack holding tuples of (node, current_sum, current_path), but recursion is less error-prone under time pressure.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Citadel.

OA at Citadel?
Invisible during screen share
Get it