FastPrepMinimum-Cost Root-to-Leaf Path in an N-ary Tree
Problems/Minimum-Cost Root-to-Leaf Path in an N-ary Tree

Minimum-Cost Root-to-Leaf Path in an N-ary Tree

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported with a return-path follow-up in a first-hand Bloomberg London graduate interview. Indexed nodes and lexicographic ties provide the portable contract.

Node i has value values[i] and child indices children[i]; root is 0. Path cost is the sum of node values from root through a leaf.

Return a long array containing cost first, followed by the node indices of a minimum-cost root-to-leaf path. Break cost ties lexicographically by index sequence.

Function

minimumCostPath(values: int[], children: int[][]) → long[]

Examples

Example 1

values = [5,2,3,1,4]children = [[1,2],[3,4],[],[],[]]return = [8,0,1,3]

Path 0,1,3 costs 5+2+1=8, less than the other leaves.

Constraints

  • 1 <= values.length == children.length <= 10^5.
  • Children form a rooted tree.

More Bloomberg LP Phone Screen questions

  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • House Robber IIIOkta · PHONE SCREENOkta interview questions
  • House Robber IIIGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • House Robber IIIVisa · PHONE SCREENVisa interview questions
  • Minimum Root-to-Leaf Cut CostGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Maximum Nonadjacent Sum in a General TreeZip · PHONE SCREEN · ONSITE INTERVIEWZip interview questions
  • Lowest Common Manager for Employee GroupsAmazon · PHONE SCREEN
  • File Encryption Tree OptimizationDatabricks · PHONE SCREEN · ONSITE INTERVIEWDatabricks interview questions
  • Maximum Path Sum Between Marked NodesDoorDash · PHONE SCREENDoorDash interview questions
  • Transitive Employee Referral CountsRobinhood · ONSITE INTERVIEWRobinhood interview questions
  • Best Sum Downward Tree PathCitadel · OACitadel interview questions

Interview reports that mention this question

  • Bloomberg New Grad Question Bank: 161 Questions (Part 1 of 2)
  • Bloomberg New Grad VOs: 32 Experiences (Part 5 of 5)
  • Bloomberg New Grad Screens: 30 Experiences (Part 4 of 5)
  • Bloomberg New Grad SWE Interviews: 98 Experiences (Part 1 of 5)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public long[] minimumCostPath(int[] values, int[][] children) {
      // Write your code here.
    }
}
Checking account…