FastPrepSum Root-to-Leaf Numbers
Problems/Sum Root-to-Leaf Numbers

Sum Root-to-Leaf Numbers

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Our version is about 95% the same as the reported question. The Bloomberg new-grad phone-screen report names this well-known problem directly. That problem gives the rule (add up the numbers formed by each root-to-leaf path of digits), the examples and the limits.

You are given the root of a binary tree whose nodes each contain one digit from 0 through 9.

Every root-to-leaf path represents a number formed by reading its digits from the root to the leaf. Return the sum of all such numbers.

A leaf is a node with no children.

Function

sumNumbers(root: TreeNode) → int

Examples

Example 1

root = [1,2,3]return = 25
root
123

The paths form 12 and 13, whose sum is 25.

Example 2

root = [4,9,0,5,1]return = 1026
root
49510

The paths form 495, 491, and 40, which sum to 1026.

Example 3

root = [0]return = 0
root
0

The only path consists of the digit 0.

Constraints

  • The tree contains between 1 and 1000 nodes.
  • 0 <= node.val <= 9.
  • The root has no leading-zero child-path ambiguity; a root value of 0 is allowed.
  • The sum of all represented numbers fits in a signed 32-bit integer.

More Bloomberg LP Phone Screen questions

  • Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • 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

Similar questions at other companies

  • Lowest Common Ancestor in a BST and a Binary TreeGreyOrange · PHONE SCREENGreyOrange interview questions
  • House Robber IIIOkta · PHONE SCREENOkta interview questions
  • Render a Task Tree from CSV RowsStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • Validate Binary Search TreeKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
  • House Robber IIIGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Binary Tree Target-Sum PathsByteDance · PHONE SCREENByteDance interview questions
  • House Robber IIIVisa · PHONE SCREENVisa interview questions
  • Find All Paths for a Name in a File SystemThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Validate a BST with a Custom ComparisonApple · PHONE SCREENApple interview questions
  • Filter Undesired Comments and Their DescendantsReddit · PHONE SCREEN · ONSITE INTERVIEWReddit interview questions

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {
    public int sumNumbers(TreeNode root) {
        // Write your code here.
    }

}
Checking account…