← Bloomberg Interview Insights

Bloomberg·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Bloomberg coding round, one problem but with a twist baked in from the start. Pretty clean interview overall, just needed to think past the standard version of the problem.

Questions Asked (1)

Q1

Given an m x n grid of land and water cells, find all islands (4-connected groups of land). Then, given an array of target sizes, return an array where each entry is the count of islands whose size exactly matches the corresponding target.

Algorithms & Data Structures
Author's notes

It's Number of Islands but you can't just count them, you need to track the size of each one.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use BFS or DFS to traverse each unvisited land cell, marking visited cells and counting the size of each island. Store island sizes in a frequency map, then for each target size, look up its count in O(1) time. This yields O(m*n + t) time and O(m*n) space.

Pro tip: Mention that you can avoid modifying the input grid by using a separate visited matrix or by temporarily mutating the grid and restoring it, and discuss trade-offs. Also, note that if the grid is very large, a union-find approach can be more cache-friendly and parallelizable.

1. Clarify and Plan

Confirm the definition of 4-connectivity, input constraints (e.g., grid size, target array size), and expected output format. Decide on traversal method (BFS/DFS) and data structures.

2. Traverse and Count Islands

Iterate through each cell; when encountering unvisited land, perform BFS/DFS to explore the entire island, marking cells as visited and counting its size.

3. Record Island Sizes

Store each island's size in a hash map (size -> frequency) or a list if sizes are bounded. This allows O(1) lookup for target sizes.

4. Answer Queries

For each target size, retrieve its frequency from the map (or 0 if absent) and append to the result array.

5. Analyze Complexity

State time complexity O(m*n + t) and space complexity O(m*n) for visited tracking, and discuss potential optimizations like union-find or early termination.

Key Points to Mention

  • 4-connectivity definition and how to handle boundaries
  • Choice of BFS vs DFS and trade-offs (stack depth, queue memory)
  • Using a visited matrix or in-place marking to avoid revisiting cells
  • Storing island sizes in a frequency map for O(1) target lookups
  • Time and space complexity analysis
  • Edge cases: empty grid, no land, target sizes larger than grid, duplicate targets

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