FastPrepMinimum Path Sum to Target in Binary Tree
Problems/Minimum Path Sum to Target in Binary Tree

Minimum Path Sum to Target in Binary Tree

Citadel logoCitadel● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

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:

  • Prefer the path with fewer nodes.
  • If lengths are equal, prefer the lexicographically smaller node-value sequence.

If no valid path exists, return an empty array.

Function

findMinimumTargetPath(levelOrder: String[], targetSum: int) → int[]

Complete the function findMinimumTargetPath in the editor below.

findMinimumTargetPath has the following parameters:

  1. String[] levelOrder: the binary tree in level-order form, using "null" for missing children
  2. int targetSum: the required path sum

Returns int[]: the chosen root-to-leaf path, or an empty array if none exists.

Examples

Example 1

levelOrder = ["5", "4", "8", "11", "null", "13", "4", "7", "2", "null", "null", "5", "1"]targetSum = 22return = [5, 4, 11, 2]

The path 5 -> 4 -> 11 -> 2 sums to 22 and is the selected valid path.

Example 2

levelOrder = ["1", "2", "3"]targetSum = 5return = []

No root-to-leaf path sums to 5, so the answer is empty.

Constraints

  • The input tree is finite and represented in level order.
  • The returned path must start at the root and end at a leaf.
  • If multiple valid paths exist, apply the required tie-breaking rules exactly.

More Citadel problems

  • Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
  • Square Root FunctionPHONE SCREEN · Seen Oct 2026
  • Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
All Citadel interview questionsSee Citadel hiring insights
Saved
class Solution {
    public int[] findMinimumTargetPath(String[] levelOrder, int targetSum) {
        // write your code here
    }

}
Checking account…