FastPrepVertical Order Traversal of a Binary Tree
Problems/Vertical Order Traversal of a Binary Tree

Vertical Order Traversal of a Binary Tree

Bloomberg LP logoBloomberg LP● HardNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names this well-known problem directly in a Bloomberg new-grad onsite. We keep its order by row, then column, then value when two nodes share a position. The tree comes as a level-order list so it works in every language.

You are given a binary tree serialized as a level-order string array levelOrder. Each non-null token is a signed decimal integer, and "null" denotes a missing child.

Place the root at row 0, column 0. A left child is at row r + 1, column c - 1, and a right child is at row r + 1, column c + 1.

Return the values grouped from the smallest column to the largest. Within each column, order nodes by increasing row. When nodes share both row and column, order their values from smallest to largest.

Function

verticalTraversal(levelOrder: String[]) → int[][]

Examples

Example 1

levelOrder = ["3","9","20","null","null","15","7"]return = [[9],[3,15],[20],[7]]

Columns run from -1 through 2; values are ordered by row inside each column.

Example 2

levelOrder = ["1","2","3","4","6","5","7"]return = [[4],[2],[1,5,6],[3],[7]]

Values 6 and 5 share row 2 and column 0, so they appear as 5, 6.

Example 3

levelOrder = []return = []

An empty tree has no vertical columns.

Constraints

  • 0 <= non-null node count <= 100000
  • Every non-null token represents a signed 32-bit integer.
  • levelOrder is a valid level-order serialization using "null" markers.

More Bloomberg LP Onsite Interview 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
  • 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
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Vertical Order Traversal of a Binary TreeTokopedia · ONSITE INTERVIEWTokopedia interview questions
  • Find All Paths for a Name in a File SystemThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Serialize and Deserialize a Binary TreeAmazon · ONSITE INTERVIEW
  • Recursive Display SortFigma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Serialize and Deserialize a Binary TreeNVIDIA · PHONE SCREENNVIDIA interview questions
  • Analyze Underpaid Managers in a Salary TreeGoogle · PHONE SCREENGoogle interview questions
  • Vertical Tree Traversal with Value TiesMeta · PHONE SCREENMeta interview questions
  • Diameter of Binary TreeeBay · ONSITE INTERVIEWeBay interview questions
  • Tree Height After Child PromotionSnowflake · PHONE SCREENSnowflake interview questions
  • Check a Complete Binary TreeGoldman Sachs · PHONE SCREENGoldman Sachs 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
class Solution {
    public int[][] verticalTraversal(String[] levelOrder) {
        // Write your code here.
    }

}
Checking account…