FastPrepBinary Tree Vertical Order Traversal
Problems/Binary Tree Vertical Order Traversal

Binary Tree Vertical Order Traversal

Bloomberg LP logoBloomberg LP● MediumNEW GRADFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in several firsthand Bloomberg new grad phone and onsite interviews. Inside each vertical column, nodes keep the order you meet them in a breadth-first walk.

Given the root of a binary tree, return its vertical order traversal.

Place the root in column 0. A left child is one column to the left of its parent, and a right child is one column to the right. Return the columns from leftmost to rightmost.

Within each column, list nodes from top to bottom. If two nodes have the same row and column, preserve their left-to-right breadth-first encounter order.

Function

verticalOrder(root: TreeNode) → int[][]

Examples

Example 1

root = [3,9,20,null,null,15,7]return = [[9],[3,15],[20],[7]]
root
3920157

The occupied columns are -1, 0, 1, and 2. Nodes 3 and 15 share column 0 and appear from top to bottom.

Example 2

root = [1,2,3,4,5,6,7]return = [[4],[2],[1,5,6],[3],[7]]
root
1245367

Nodes 5 and 6 have the same row and column. Breadth-first left-to-right order places 5 before 6.

Example 3

root = []return = []
root
empty

An empty tree has no columns.

Constraints

  • The tree contains at most 1000 nodes.
  • -1000 <= Node.val <= 1000.

More Bloomberg LP Phone Screen questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE 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
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
  • Vertical Order Traversal of a Binary TreeAmazon · ONSITE INTERVIEW
  • Binary Tree Vertical Order TraversalGoogle · ONSITE INTERVIEWGoogle interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Find All Paths for a Name in a File SystemThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Worst-Performing Ads by CTR in a Campaign TreeUber · PHONE SCREENUber interview questions
  • Group Identical Tree LevelsSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Top-Down Employee Reporting ForestOkta · ONSITE INTERVIEWOkta interview questions
  • Merge N-Ary Trees by KeyLinkedIn · PHONE SCREEN · ONSITE INTERVIEWLinkedIn interview questions
  • Diff Two Filesystem Hash TreesCursor · PHONE SCREENCursor interview questions

Interview reports that mention this question

  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg New Grad Question Bank: 161 Questions (Part 1 of 2)
  • Bloomberg New Grad Screens: 30 Experiences (Part 4 of 5)
  • Bloomberg New Grad OOD Follow-ups: 14 Experiences (Part 3 of 5)
  • Bloomberg New Grad SWE Offer Loops: 14 Experiences (Part 2 of 5)
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[][] verticalOrder(TreeNode root) {
        // Write your code here.
    }
}
Checking account…