← Bloomberg Interview Insights

Bloomberg·Software Engineer·Online Assessment (OA)·Intermediate

Intermediate
Jun 2026

Summary

Bloomberg SWE online assessment with three coding problems and 20 MCQs. The problems ranged from array manipulation to graph traversal to combinatorics, and the MCQs were on top of all that. Pretty dense for a single sitting.

Questions Asked (3)

Q1

You have n servers each with a state of 0 or 1. You can pick any consecutive subarray and flip all values in it. After the flip, the redundancy is the number of distinct counts of operational servers across all possible configurations. Find the maximum redundancy achievable.

Algorithms & Data Structures
Author's notes

This one took me a while to even understand what was being asked.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem statement and constraints, as the phrasing is ambiguous. Then, model the effect of flipping a subarray on the number of operational servers, and determine how to maximize the number of distinct counts achievable. Consider the range of possible counts and whether all values in that range can be achieved.

Pro tip: Don't rush to code; demonstrate strong communication by restating the problem in your own words and confirming assumptions with the interviewer. This shows you prioritize understanding over speed.

1. Clarify the problem

Ask questions to resolve ambiguities: What exactly is 'redundancy'? Is it the number of distinct counts of 1s across all possible configurations after any number of flips? Are we allowed to flip any subarray any number of times?

2. Define variables and operations

Let the initial array have k ones. Flipping a subarray of length L changes the number of ones by L - 2*(number of ones in the subarray). The new count can be any integer between 0 and n, but not all may be reachable.

3. Determine reachable counts

Analyze which counts of 1s are achievable. Since you can flip any subarray, you can effectively change the count by any even number? Actually, flipping a single element changes count by ±1, so any count between 0 and n is achievable if you can flip individual elements. But flipping a subarray flips multiple elements at once; however, by flipping overlapping subarrays, you can achieve any count.

4. Maximize distinct counts

If any count from 0 to n is achievable, then the maximum redundancy is n+1. But check if there are constraints: e.g., if you can only flip once, then the reachable counts are limited. The problem says 'you can pick any consecutive subarray and flip all values in it' — it doesn't specify a limit on the number of flips. So likely multiple flips are allowed, making all counts reachable.

5. Consider edge cases and prove

Verify with small n: n=1, initial [0] -> flip [0] gives [1], counts {0,1} -> redundancy 2 = n+1. n=2, initial [0,0] -> flip [0,0] gives [1,1] count 2; flip [0] gives [1,0] count 1; so counts {0,1,2} -> redundancy 3. So answer is n+1.

Key Points to Mention

  • Clarify the definition of redundancy and whether multiple flips are allowed.
  • The effect of flipping a subarray on the number of 1s.
  • The range of possible counts of 1s after any sequence of flips.
  • Proof that all counts from 0 to n are achievable (e.g., by flipping individual elements or using induction).
  • Edge cases for small n to validate the formula.
  • Time and space complexity: O(1) solution if the answer is simply n+1.

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

Q2

Given a network of devices where each device has a frequency of 1, 2, or 3, two devices can communicate if there's a simple path between them where consecutive devices differ in frequency by at most 1. Find the maximum distance between any two communicating devices.

Algorithms & Data StructuresSystem Design
Author's notes

Graph problem with a constraint on edges you can actually traverse.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the network as a graph where edges connect devices with frequency difference ≤1. The problem reduces to finding the diameter of each connected component, then taking the maximum across all components. Use BFS from any node to find the farthest node, then BFS from that node to find the diameter.

Pro tip: Clarify whether the graph is a tree or general graph; if general, the double-BFS method only works for trees, so you may need to run BFS from every node or use more advanced algorithms. Also, consider edge cases like disconnected components and single-node components.

1. Model as Graph

Represent devices as nodes and add edges between devices whose frequency difference is at most 1. This creates a graph where communication corresponds to connectivity.

2. Identify Connected Components

Use BFS or DFS to find all connected components. The maximum distance must be within a single component.

3. Compute Diameter per Component

For each component, compute its diameter (longest shortest path). If the component is a tree, use double BFS; otherwise, use BFS from each node or Floyd-Warshall for small graphs.

4. Return Maximum Diameter

Take the maximum diameter across all components as the final answer. Handle edge cases like empty graph or isolated nodes.

Key Points to Mention

  • Graph modeling: nodes as devices, edges based on frequency difference ≤1
  • Connected components and why distance is only defined within a component
  • Diameter of a graph: longest shortest path
  • Double BFS technique for trees and its limitations for general graphs
  • Time complexity: O(V+E) for tree components, O(V*(V+E)) for general graphs
  • Edge cases: disconnected graph, single node, no edges

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

Q3

Given an array of response times for n components, every non-empty subset forms a pipeline whose response time is (max element in subset) times (size of subset). Return the sum of all pipeline response times across all non-empty subsets, modulo 10^9 + 7.

Algorithms & Data Structures
Author's notes

This is the kind of problem where brute force is obvious but clearly won't scale.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Sort the array and use a contribution technique: for each element as the maximum, compute its contribution to the sum over all subsets where it is the maximum. The contribution of the i-th smallest element is arr[i] * (sum_{k=1}^{i+1} k * C(i, k-1)) modulo 1e9+7. Precompute binomial coefficients and powers of two to compute the sum efficiently.

Pro tip: Derive a closed-form for the inner sum: sum_{k=1}^{m} k * C(m-1, k-1) = 2^{m-2} * (m+1) for m >= 1, which simplifies the computation to O(n log n) after sorting. Mention that this avoids O(n^2) and shows strong mathematical insight.

1. Clarify and Sort

Confirm the problem details: subsets are non-empty, order doesn't matter, and modulo is 1e9+7. Sort the array to easily identify maximums.

2. Contribution Technique

For each element, consider it as the maximum of a subset. Count how many subsets have this element as maximum and compute the sum of sizes of those subsets.

3. Combinatorial Counting

If the element is at index i (0-based) in sorted order, there are i elements smaller. For a subset of size k (1 ≤ k ≤ i+1), choose k-1 from the i smaller elements. The sum of sizes is sum_{k=1}^{i+1} k * C(i, k-1).

4. Simplify with Closed Form

Use the identity sum_{k=1}^{m} k * C(m-1, k-1) = 2^{m-2} * (m+1) for m ≥ 1, where m = i+1. This reduces the per-element computation to O(1) after precomputing powers of two.

5. Compute and Modulo

Iterate through the sorted array, compute each element's contribution as arr[i] * (2^{i-1} * (i+2)) mod MOD, sum them up, and return the result modulo 1e9+7.

Key Points to Mention

  • Sorting the array to establish a clear ordering for maximums.
  • Contribution technique: summing over each element's role as the maximum.
  • Combinatorial counting: choosing subsets of various sizes from smaller elements.
  • Closed-form simplification using binomial identities and powers of two.
  • Time complexity: O(n log n) due to sorting, with O(n) additional computation.
  • Handling modulo arithmetic correctly to avoid overflow.

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