← Bloomberg Interview Insights

Bloomberg·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Bloomberg SWE interview with a tree traversal problem that looks straightforward until you work through the column indexing logic. The follow-up was just reversing the output, which felt almost too easy after the main part.

Questions Asked (2)

Q1

Given a binary tree, perform a traversal and output one character per vertical column. For each column, pick the deepest node; if there's a tie in depth, pick the rightmost one. Concatenate the results left to right by column index.

Algorithms & Data Structures
Author's notes

The column tracking is the real puzzle here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a BFS traversal while tracking each node's horizontal distance (column index) from the root. For each column, maintain the deepest node seen so far, updating when a node is deeper or at the same depth but further right. Finally, collect the characters from the leftmost to rightmost column and concatenate them.

Pro tip: Clarify the tie-breaking rule upfront: 'rightmost' means the node with the largest horizontal distance within the same column? Actually, within a column, rightmost is ambiguous; typically it means the node that appears later in a level-order traversal (i.e., further right in the tree). Confirm with the interviewer to avoid misinterpretation.

1. Clarify the problem

Ask clarifying questions about the tie-breaking rule for 'rightmost' within the same column and depth, and confirm the output format (e.g., string of characters).

2. Choose traversal and track columns

Use BFS (level-order) to process nodes level by level, which naturally handles depth. Maintain a map from column index to the best node (deepest, then rightmost) found so far.

3. Update best node per column

For each node, compute its column index (root at 0, left child -1, right child +1). If the column is new or the current node is deeper, or same depth but appears later in BFS order (rightmost), update the map.

4. Collect and concatenate

After traversal, determine the min and max column indices, then iterate from min to max, appending the character from the best node in each column to form the result string.

Key Points to Mention

  • BFS ensures nodes are processed in level order, so depth is naturally tracked.
  • Horizontal distance (column index) can be tracked using a queue of (node, column) pairs.
  • Tie-breaking: when depths are equal, the node encountered later in BFS (rightmost) should be chosen.
  • Use a hash map to store the best node for each column, updating as needed.
  • Edge cases: empty tree, single node, skewed tree, and columns with only one node.
  • Time complexity O(N) and space complexity O(N) where N is the number of nodes.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Follow-up: now output the same result but in reverse column order, right to left.

Algorithms & Data Structures
Author's notes

Just reverse the string at the end.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify that the follow-up asks for the same result but with columns reversed (right-to-left). Then, adapt your previous solution by either reversing the column order in the output or iterating columns from last to first, ensuring the row order remains unchanged.

Pro tip: Mention that reversing column order can be done in-place by swapping symmetric columns, which is O(n) time and O(1) space, and discuss trade-offs with creating a new matrix.

1. Clarify the requirement

Confirm that 'reverse column order' means the first column becomes the last, the second becomes the second-last, etc., while rows stay in the same order.

2. Recall the original solution

Briefly restate the approach used for the original problem (e.g., matrix traversal, transformation) to establish a baseline.

3. Adapt for column reversal

Modify the original solution by either reversing the column indices during output or by swapping columns symmetrically in-place.

4. Analyze complexity

State the time and space complexity of the adapted solution, noting any changes from the original.

5. Test with examples

Walk through a small example (e.g., 2x3 matrix) to verify the column reversal works correctly and edge cases are handled.

Key Points to Mention

  • In-place column reversal using two pointers (left and right) to swap columns.
  • Time complexity O(m * n) for an m x n matrix, space complexity O(1) if in-place.
  • Alternative: create a new matrix with reversed columns, O(m * n) space.
  • Handling non-square matrices and ensuring row order is preserved.
  • Edge cases: empty matrix, single row, single column.
  • Comparison with reversing rows or reversing both rows and columns.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.