← Bloomberg Interview Insights

Bloomberg·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Bloomberg SWE coding round with a two-part problem that combined graph-based ordering with a substring frequency question. The second part got a bit chaotic mid-interview when the scope changed, which was a whole thing.

Questions Asked (2)

Q1

Given a sorted dictionary from an alien language, determine the ordering of its characters.

Algorithms & Data Structures
Author's notes

Classic topological sort problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a directed graph where each character is a node and edges represent the relative order derived from adjacent word comparisons. Then perform a topological sort to determine a valid character ordering, detecting cycles to handle invalid inputs.

Pro tip: Clarify edge cases upfront, such as duplicate words, empty strings, and cycles, and discuss how you would handle them. Mention that the solution is essentially topological sorting and that you would use Kahn's algorithm or DFS, showing awareness of time and space complexity.

1. Clarify and Validate Input

Confirm assumptions: dictionary is sorted, words are non-empty, and characters are from a finite alphabet. Discuss handling of invalid inputs like cycles or duplicate words.

2. Build the Graph

Iterate through adjacent word pairs, find the first differing character, and add a directed edge from the first to the second. Track all unique characters as nodes.

3. Topological Sort

Perform topological sorting using DFS or BFS (Kahn's algorithm) to produce a linear ordering of characters. Detect cycles to determine if a valid ordering exists.

4. Handle Edge Cases

Address cases like a cycle (return empty string), a prefix word appearing after a longer word (invalid), and multiple valid orderings (return any).

5. Analyze Complexity

State time complexity O(C + N) where C is total characters and N is number of unique characters, and space complexity O(N + E) for the graph.

Key Points to Mention

  • Graph representation: adjacency list for characters
  • Topological sorting algorithms: DFS with cycle detection or Kahn's algorithm
  • Cycle detection to identify invalid input
  • Handling of prefix cases where a shorter word comes after a longer word
  • Time and space complexity analysis
  • Edge cases: duplicate words, empty strings, single word, all characters unique

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

Q2

Given a string and integer k, find the length of the longest substring where every character appears at least k times.

Algorithms & Data Structures
Author's notes

This one got weird.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a divide-and-conquer strategy: split the string at characters that appear fewer than k times, then recursively find the longest valid substring in each part. Alternatively, use a sliding window with a fixed number of distinct characters, iterating over all possible distinct counts from 1 to 26.

Pro tip: Discuss the trade-offs between the divide-and-conquer and sliding window approaches, and mention that the sliding window approach can be optimized to O(26*n) time, which is effectively O(n).

1. Clarify the problem

Confirm that the substring must be contiguous and that every character in the substring must appear at least k times. Ask about constraints on string length and character set.

2. Discuss brute force

Mention that checking all substrings would be O(n^2) or O(n^3) and is inefficient for large inputs.

3. Propose divide-and-conquer

Explain that if a character appears fewer than k times in the whole string, it cannot be part of any valid substring, so split at that character and recurse on the parts.

4. Propose sliding window with distinct count

For each possible number of distinct characters (1 to 26), use a sliding window to find the longest substring with exactly that many distinct characters where each appears at least k times.

5. Analyze complexity and choose

Compare time and space complexity: divide-and-conquer is O(n * 26) in worst case but can be O(n log n) on average; sliding window is O(26 * n) = O(n). Discuss which is more suitable based on constraints.

Key Points to Mention

  • The problem requires every character in the substring to have frequency >= k.
  • Divide-and-conquer: split at characters with total frequency < k.
  • Sliding window: iterate over number of distinct characters (1 to 26).
  • Time complexity: O(26 * n) for sliding window, effectively O(n).
  • Space complexity: O(1) extra space for sliding window (fixed array of size 26).
  • Edge cases: k=1 (whole string), k > length (return 0), empty string.

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