FastPrepLargest Value in Each Tree Row
Problems/Largest Value in Each Tree Row

Largest Value in Each Tree Row

Bloomberg LP logoBloomberg LP● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Our version is about 99% the same as the reported question. The Bloomberg new-grad virtual-onsite report names this well-known problem directly. That problem gives the rule (the largest value in each row), the examples and the limits.

Given the root of a binary tree, return the largest node value at every depth, ordered from the root level downward.

Return an empty list when the tree is empty.

Function

largestValues(root: TreeNode) → List<Integer>

Examples

Example 1

root = [1,3,2,5,3,null,9]return = [1,3,9]
root
135329

The maximum values at depths zero, one, and two are 1, 3, and 9.

Example 2

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

The root is the only value at depth zero, and 3 is the larger child at depth one.

Example 3

root = []return = []
root
empty

An empty tree has no rows.

Constraints

  • The tree contains between 0 and 10000 nodes.
  • -2147483648 <= node.val <= 2147483647.

More Bloomberg LP Onsite Interview 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
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Diagonal Traversal of a Binary TreeAmazon · ONSITE INTERVIEW
  • Delete Nodes and Return Forest RootsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Diameter of an Acyclic Undirected GraphSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Binary Tree Zigzag TraversalExpedia · ONSITE INTERVIEWExpedia interview questions
  • Top View of a Binary TreeInMobi · ONSITE INTERVIEWInMobi interview questions
  • Maximum Value at Each Tree LevelMeta · ONSITE INTERVIEWMeta interview questions
  • Diameter of Binary TreeeBay · ONSITE INTERVIEWeBay interview questions
  • Maximum Depth of Binary TreeLinkedIn · PHONE SCREEN · ONSITE INTERVIEWLinkedIn interview questions
  • Symmetric Binary TreeFigma · ONSITE INTERVIEWFigma interview questions
  • Mirror a Binary TreeAMD · ONSITE INTERVIEWAMD 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 List<Integer> largestValues(TreeNode root) {
        // Write your code here.
    }

}
Checking account…