Decode a Binary Tree by Vertical Traversal
Updated
Problem statement
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) → StringExamples
Example 1
root = [114,101,116,null,null,101,null,99,null,115]return = "secret"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"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^5nodes. - 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)