FastPrepDecode a Binary Tree by Vertical Traversal
Problems/Decode a Binary Tree by Vertical Traversal

Decode a Binary Tree by Vertical Traversal

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported through two prompt-bearing diagrams in a first-hand Bloomberg 2020 new-grad phone interview. Integer node values encode lowercase ASCII characters.

Each node value is the ASCII code of a lowercase letter. Give root column 0, left child column-1, and right child column+1. Read columns from smallest to largest; within a column read top-to-bottom, breaking same-row ties by left-to-right BFS discovery.

Concatenate the letters and return the decoded string.

Function

decodeVerticalTree(root: TreeNode) → String

Examples

Example 1

root = [114,101,116,null,null,101,null,99,null,115]return = "secret"
root
11410111610199115

Columns spell s, ec, re, t from left to right.

Example 2

root = [101,115,114,null,99,null,null,null,101,null,116]return = "secret"
root
10111599101116114

The letters are e (root), s and r (its children), then c, e and t going down to the right from s. Their columns are: s in column -1; e and c in column 0; r and e in column 1; t in column 2. Reading the columns from left to right gives s, ec, re, t, which spells "secret".

Constraints

  • The tree contains at most 10^5 nodes.
  • Values are ASCII codes 97 through 122.

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
  • Bottom View of a Binary TreeOracle · PHONE SCREEN · ONSITE INTERVIEWOracle interview questions
  • Transform and Prune a Mode-Valued Binary TreeGoogle · PHONE SCREENGoogle interview questions
  • Everyone Under a ManagerAdobe · PHONE SCREENAdobe interview questions
  • Team Cost Under a ManagerRippling · PHONE SCREENRippling interview questions
  • Path Between Two Binary-Tree NodesSnowflake · PHONE SCREENSnowflake interview questions
  • Group Identical Tree LevelsSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Count LevelsBlackRock · OABlackRock interview questions
  • Vertical Order Traversal of a Binary TreeAmazon · ONSITE INTERVIEW
  • Binary Tree Vertical Order with Stable TiesMeta · ONSITE INTERVIEWMeta 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 String decodeVerticalTree(TreeNode root) {
      // Write your code here.
    }
}
Checking account…