Bloomberg logo

Bloomberg Software Engineer Coding Questions

20 practice questions for Bloomberg Software Engineer interviews

Bloomberg software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Hard Verified Question #1

1. Dual Extremes Queue


Category: Queue-based coding problem
Design a StreamBuffer class that buffers a stream of integer latency samples in FIFO order and supports O(1) access to both the minimum and maximum...
Input: Integer(s)
Output: Integer
Want to practise this one?
Create a free account to open the full question and practise Bloomberg questions with AI.
Sign up free
coding Hard Verified Question #2

2. Fuel Grid Navigation


Category: Grid/matrix coding problem

Question You are navigating a grid from a start cell S to a destination cell D. Your vehicle has a fuel tank with a maximum capacity. Moving...

Input: 2D grid
Output: Integer
coding Easy Verified Question #3

3. Hailstone Sequence Steps


Category: Algorithm coding problem

Question The Hailstone sequence starts from a positive integer n and repeatedly applies the following rules until reaching 1: - If n is...

Input: Integer(s)
Output: Integer
coding Easy Verified Question #4

4. Trade Volume Tracker


Category: Algorithm coding problem

Question Design a TradeVolumeTracker class that records trade volumes by ticker symbol and returns an ordered ranking of tickers by volume. The...

Input: List
Output: Array
coding Easy Verified Question #5

5. Word Puzzle Filter


Category: Algorithm coding problem

Question You are implementing a word filter for a puzzle game. Given a list of candidate words and a set of allowed letters plus one required...

Input: List
Output: Array
coding Medium Verified Question #6

6. Equivalence Groups


Category: Array coding problem

Question You are given an array of integers and an equivalence function equiv(x, y) that returns true if two values belong to the same group....

Input: Array of integers
Output: Computed result
coding Medium Verified Question #7

7. Densest Tree Level


Category: Tree coding problem

Question You are given an N-ary tree where each node has a value and a list of children. Return the 1-indexed level that contains the most nodes....

Input: List
Output: Computed result
coding Easy Verified Question #8

8. Uniform String


Category: String coding problem

Question A string is called uniform if all of its characters appear the same number of times. Given a string s, determine whether it can...

Input: String
Output: Computed result
coding Medium Verified Question #9

9. Stream Palindrome


Category: Palindrome coding problem

Question Design a StreamPalindrome class that processes a stream of characters one at a time. At any point, it should be able to report whether...

Input: Given input
Output: Computed result
coding Easy Verified Question #10

10. Tree Min Leaf Sum


Category: Tree coding problem

Question You are given an N-ary tree where each node has an integer value. Find the minimum sum path from the root to any leaf node and return that...

Input: Integer(s)
Output: Integer
coding Medium Verified Question #11

11. Multi File Word Search


Category: Algorithm coding problem

Question You are given a list of documents where each document has a name and a body of text. Given a search query word, find and return all...

Input: List
Output: Array
coding Hard sliding window #1

1. [AI Enabled Coding] Trade Surveillance Rule Engine


Scenario
Bloomberg Trade Order Management Solutions (TOMS) supports institutional trading workflows. Build a prototype surveillance component for USD-denominated execution records that lets operations analysts identify unusually large executions, conflicting operator locations, and concentrated desk activity. The policies below are interview assumptions, not claims about Bloomberg's production surveillance rules; you may use an AI assistant while implementing and testing them.
Part 1 — Execution-level alerts
  • Each record has string-valued fields id, trader, desk, city, minute, and amount_usd. Minutes are absolute integer timestamps, not times of day; inputs may be unsorted.

  • AMOUNT_LIMIT: flag an execution when its amount is strictly greater than 1000.00 USD.

  • CITY_CONFLICT: flag an execution if another execution by the same trader occurred in a different city within 60 minutes inclusive, before or after it. Flag both executions in a conflicting pair, even across desks.

  • Evaluate rules independently against all original records. An execution that triggers one rule still participates in every other rule.

  • Return one result per input record, in input order, containing its ID and alphabetically sorted, unique rule names. Records without alerts must also appear.

  • Implement evaluate_executions(records: list[dict[str, str]]). The concrete return type is up to the candidate; the JSON below defines its observable contents.


Example 1:
Input:
{"records":[{"id":"a","trader":"u","desk":"A","city":"NYC","minute":"0","amount_usd":"1000.00"},{"id":"b","trader":"u","desk":"A","city":"London","minute":"60","amount_usd":"1000.01"},{"id":"c","trader":"u","desk":"A","city":"NYC","minute":"121","amount_usd":"500.00"},{"id":"d","trader":"v","desk":"B","city":"London","minute":"30","amount_usd":"400.00"},{"id":"e","trader":"v","desk":"B","city":"NYC","minute":"91","amount_usd":"100.00"}]}

Output:
[{"id":"a","rules":["CITY_CONFLICT"]},{"id":"b","rules":["AMOUNT_LIMIT","CITY_CONFLICT"]},{"id":"c","rules":[]},{"id":"d","rules":[]},{"id":"e","rules":[]}]

Explanation: a and b differ in city and are exactly 60 minutes apart. Only b exceeds 1000.00. The gaps from b to c and from d to e are 61 minutes, so those pairs do not conflict.
Part 2 — Configurable desk-window policies
Other surveillance teams now need desk-level rolling notional policies. Extend the function to evaluate_executions(records: list[dict[str, str]], desk_rules: list[dict[str, str]] | None = None) without replacing the Part 1 rules.
  • Each desk rule has string fields name, window_minutes, and cap_usd.

  • For an execution at minute t, sum amounts for its desk across all traders in the inclusive interval [t - window_minutes, t]. Include all executions tied at t, irrespective of input order.

  • Flag that execution with the configured rule name if the sum is strictly greater than cap_usd. This does not automatically flag other members of its window; each execution is evaluated at its own timestamp.

  • Previously flagged executions still contribute their full amounts. Desks are independent.

  • When desk_rules is provided, return an object containing records, with the Part 1 result shape, and breaches, with one {id, rule, total_usd} item per violated desk rule. Format totals with exactly two decimal places. Order breaches by input-record position, then rule name. An empty configuration list still selects this extended output shape.

  • The design must support future desk-window policies through configuration and future rule implementations without rewriting the existing rules. Discuss how the return type changes before implementing the extension.


Example 2:
Input:
{"records":[{"id":"p","trader":"p1","desk":"A","city":"NYC","minute":"0","amount_usd":"900.00"},{"id":"q","trader":"q1","desk":"A","city":"NYC","minute":"30","amount_usd":"900.00"},{"id":"r","trader":"r1","desk":"A","city":"NYC","minute":"60","amount_usd":"800.00"},{"id":"s","trader":"s1","desk":"A","city":"NYC","minute":"61","amount_usd":"1000.00"}],"desk_rules":[{"name":"DESK_60M","window_minutes":"60","cap_usd":"2500.00"}]}

Output:
{"records":[{"id":"p","rules":[]},{"id":"q","rules":[]},{"id":"r","rules":["DESK_60M"]},{"id":"s","rules":["DESK_60M"]}],"breaches":[{"id":"r","rule":"DESK_60M","total_usd":"2600.00"},{"id":"s","rule":"DESK_60M","total_usd":"2700.00"}]}

Explanation: The totals at minutes 0 and 30 are 900.00 and 1800.00. At minute 60, the inclusive window contains p + q + r = 900 + 900 + 800 = 2600, exceeding 2500. At minute 61, p expires, giving q + r + s = 900 + 800 + 1000 = 2700. No execution exceeds the individual amount limit, and every trader is distinct.
Example 3:
Input:
{"records":[{"id":"x","trader":"u","desk":"A","city":"London","minute":"60","amount_usd":"1500.00"},{"id":"y","trader":"u","desk":"A","city":"NYC","minute":"0","amount_usd":"1000.00"},{"id":"z","trader":"v","desk":"A","city":"NYC","minute":"60","amount_usd":"0.00"},{"id":"w","trader":"u","desk":"A","city":"NYC","minute":"120","amount_usd":"1000.00"},{"id":"v","trader":"k","desk":"B","city":"NYC","minute":"60","amount_usd":"999.00"}],"desk_rules":[{"name":"DESK_60M","window_minutes":"60","cap_usd":"2000.00"}]}

Output:
{"records":[{"id":"x","rules":["AMOUNT_LIMIT","CITY_CONFLICT","DESK_60M"]},{"id":"y","rules":["CITY_CONFLICT"]},{"id":"z","rules":["DESK_60M"]},{"id":"w","rules":["CITY_CONFLICT","DESK_60M"]},{"id":"v","rules":[]}],"breaches":[{"id":"x","rule":"DESK_60M","total_usd":"2500.00"},{"id":"z","rule":"DESK_60M","total_usd":"2500.00"},{"id":"w","rule":"DESK_60M","total_usd":"2500.00"}]}

Explanation: x exceeds the individual limit and conflicts with both y and w, each exactly 60 minutes away. At minute 60, both x and z see y + x + z = 1000 + 1500 + 0 = 2500. At minute 120, w sees x + z + w = 1500 + 0 + 1000 = 2500; already-flagged x is not excluded. These totals exceed 2000. At minute 0, desk A totals 1000; desk B independently totals 999 at minute 60.
Notes:
  • There are at most 200,000 executions and 20 configured desk rules. Avoid enumerating conflicting pairs or rescanning a window for every execution; target O(n log n + kn + k log k) time for n executions and k desk rules.

  • Inputs are valid: IDs are unique, timestamps are nonnegative integers, amounts and caps are nonnegative USD strings with exactly two fractional digits, and windows are integers from 1 through 1440. Use exact monetary arithmetic.

  • Rule names are unique and cannot collide with built-in names; identifiers and city names are case-sensitive. This is a batch evaluation, and no state persists between calls.
Want to practise this one?
Create a free account to open the full question and practise Bloomberg questions with AI.
Sign up free
coding Hard binary search #2

2. [Divide and Conquer] — Count ships using a restricted geographic query API


Background
Bloomberg's commodity-market coverage includes shipping activity, where geographic queries can help analysts understand vessel movements. This problem models counting vessels when the underlying location service exposes only an existence query; counting ships in a rectangle was reported in a Bloomberg C++ developer interview.
Problem statement
You are given a Sea API and an axis-aligned rectangle defined by integer-coordinate points bottom_left and top_right. Each ship occupies a distinct integer-coordinate point.
The API method has_ships(top_right, bottom_left) returns true if at least one ship lies inside the specified rectangle, including its boundaries, and false otherwise. It does not reveal ship locations or counts. You may call it only with a valid rectangle.
Implement count_ships to return the exact number of ships in the requested rectangle using at most 400 API calls. There are at most 10 ships in the entire coordinate domain. You cannot inspect the API's internal data, and ships outside the requested rectangle must not be counted.
Function or class signature
  • Provided API: Sea.has_ships(top_right: tuple[int, int], bottom_left: tuple[int, int]) -> bool

  • Implement: count_ships(sea: Sea, top_right: tuple[int, int], bottom_left: tuple[int, int]) -> int


Each tuple is ordered as (x, y).
Example 1:
  • Input: Hidden ship locations are [(1, 1), (2, 2), (3, 3), (8, 8)]; top_right = (4, 4); bottom_left = (1, 1).

  • Output: 3

  • Explanation: The first three ships lie within the requested rectangle. The ship at (1, 1) is included because boundaries are inclusive; (8, 8) is outside. Locations are shown only to explain the example and are not supplied to your function.


Example 2:
  • Input: Hidden ship locations are [(0, 0), (5, 0), (5, 5)]; top_right = (5, 0); bottom_left = (1, 0).

  • Output: 1

  • Explanation: This rectangle is a horizontal line segment. It includes (5, 0), excludes (0, 0), and does not include (5, 5).


Constraints:
  • All coordinates are integers in [0, 1000].

  • bottom_left.x <= top_right.x and bottom_left.y <= top_right.y.

  • There are between 0 and 10 ships in the entire domain, with no duplicate locations.

  • Ship locations remain unchanged during execution, and API responses are exact.

  • Each invocation of count_ships may make at most 400 API calls.

  • The implementation must use only the provided API to obtain information about ships.


Follow-up:
Suppose coordinates range from 0 to 10^9, and the maximum ship count is an input parameter K. Derive an API-call bound in terms of K and the rectangle's dimensions, and explain whether a fixed 400-call budget can still be guaranteed.
coding Medium graph #3

3. Graph — Shortest Path in a Stock Price Network

Background: Bloomberg's trading systems need to quickly determine the optimal trading paths for stocks to minimize transaction costs. This involves navigating a graph of stock prices, which can change frequently based on market conditions.
Problem statement: You are tasked with implementing a function that calculates the shortest path from a given stock to another where each edge weight represents the transaction cost between two stocks in an undirected graph. You need to handle multiple queries and return the minimum cost for each path efficiently. Use Dijkstra's algorithm for this task.
Function/class signature:
  • def min_transaction_cost(prices: List[Tuple[int, int, int]], queries: List[Tuple[int, int]]) -> List[int]:


Example 1:
Input: prices = [(1, 2, 100), (1, 3, 200), (2, 3, 50)], queries = [(1, 3), (1, 2)]
Output: [150, 100]
Explanation: The shortest path from 1 to 3 is via 2 with a cost of 150. The direct cost from 1 to 2 is 100.
Example 2:
Input: prices = [(1, 4, 300), (4, 5, 100), (1, 5, 600)], queries = [(1, 5), (1, 4)]
Output: [400, 300]
Explanation: The shortest path from 1 to 5 is via 4 with a total cost of 400.
Constraints:
  • 1 <= prices.length <= 10^4

  • 1 <= queries.length <= 10^4

  • 1 <= prices[i][0], prices[i][1] <= 10^6

  • 0 <= prices[i][2] <= 10^4

  • Each query node exists in the price list.
coding Medium heap #4

4. Heap — Find the Kth Largest Element in a Stream

Background: Bloomberg processes vast amounts of market data in real time. Often, traders need quick access to key metrics like the Kth largest price from a stream of stock prices for decision making.
Problem statement: Implement a class that can efficiently retrieve the Kth largest element from a stream of numbers. You should maintain the Kth largest element at all times as new numbers are added. Class should support adding a new number and retrieving the Kth largest number.
Function/class signature:
  • class KthLargest:

  • def __init__(self, k: int, nums: List[int]) -> None:

  • def add(self, val: int) -> int:


Example 1: With Input: k = 3, nums = [4, 5, 8, 2] → Output after add(3): 4, Explanation: The current stream is [4, 5, 8, 2, 3], and the 3rd largest number is 4.
Example 2: With Input: k = 1, nums = [] → Output after add(5): 5, Explanation: There is only one number 5, which is the 1st largest by default.
Constraints:
  • 1 <= k <= 10^4

  • -10^4 <= nums[i] <= 10^4

  • -10^4 <= val <= 10^4

  • At most 10^4 calls will be made to add.

  • It is guaranteed that add will be called at least once.

coding Medium graph #5

5. Graphs — Find the shortest path in a network of connections

Background: Bloomberg operates with vast datasets and real-time financial information. To ensure efficient communication and data retrieval, determining the shortest path in a network of connections, such as between servers or financial instruments, is crucial.
Problem statement: Given a graph represented as an adjacency list where each edge has a weight, write a function to calculate the shortest path from a specified starting node to all other nodes in the graph. The function should return a dictionary with nodes as keys and their shortest distances from the start node as values.
Function/class signature:
  • def shortest_path(graph: Dict[str, List[Tuple[str, int]]], start: str) -> Dict[str, int]:

Example 1:
Input: graph = { 'A': [('B', 1), ('C', 4)], 'B': [('C', 2)], 'C': []}, start = 'A'
Output: {'A': 0, 'B': 1, 'C': 3}
Explanation: Starting from A, the shortest path to B is 1 and to C is 3 via B.
Example 2:
Input: graph = { 'X': [('Y', 5)], 'Y': [('Z', 1)], 'Z': []}, start = 'X'
Output: {'X': 0, 'Y': 5, 'Z': 6}
Explanation: Starting from X, the shortest path to Y is 5 and to Z is 6.
Constraints:
  • The number of nodes in the graph will be between 1 and 1000.

  • The weights of edges will be positive integers not exceeding 100.
coding Hard dynamic programming #6

6. Dynamic Programming — Maximize Profit from Stock Trading

Background: In the financial domain, Bloomberg provides tools for stock market analysis, including trading strategies. Understanding how to maximize profit through stock trading is crucial for building robust trading systems.
Problem statement: You are given an array of integers where each integer represents the price of a stock on a given day. You can complete at most k transactions (i.e., buy and sell the stock). Your goal is to maximize your profit. You can assume that you cannot sell a stock before you buy it.
You need to implement a function that calculates the maximum profit that can be achieved with at most k transactions.
Function signature:
def max_profit(k: int, prices: List[int]) -> int:

Example 1:
Input: k = 2, prices = [2, 4, 1, 7, 5]
Output: 7
Explanation: Buy on day 1 (price = 2) and sell on day 2 (price = 4), profit = 2. Buy on day 3 (price = 1) and sell on day 4 (price = 7), profit = 6. Total profit = 2 + 6 = 8.
Example 2:
Input: k = 1, prices = [3, 2, 6, 5, 0, 3]
Output: 4
Explanation: Buy on day 2 (price = 2) and sell on day 3 (price = 6), profit = 6 - 2 = 4.
Constraints:
  • 1 <= k <= 100

  • 0 <= prices.length <= 1000

  • 0 <= prices[i] <= 1000

coding Medium tree #7

7. Binary Tree - Find Depth of Binary Tree

Background: Bloomberg often works with complex financial data that can be represented as hierarchical structures, such as trees. Efficient algorithms to traverse and analyze these structures are vital for data representation and visualization.
Problem statement: Given a binary tree, write a function that calculates the depth of the tree. The depth is defined as the number of nodes along the longest path from the root node down to the farthest leaf node.
Function/class signature:
  • def maxDepth(root: Optional[TreeNode]) -> int:

Example 1:
Input: root = [3,9,20,null,null,15,7]
Output: 3
Explanation: The longest path is from root (3) to leaf (15) or (7), which counts as 3 nodes.
Example 2:
Input: root = [1,null,2]
Output: 2
Explanation: The longest path is from root (1) to leaf (2), which counts as 2 nodes.
Constraints:
  • The number of nodes in the tree is in the range [0, 10^4].

  • -100 <= Node.val <= 100

  • The tree can have up to 10^4 nodes.
coding Medium graph #8

8. Graph Traversal — Find the Shortest Path in a Stock Network

1. Background: Bloomberg manages vast amounts of financial data including stock market information. Understanding the shortest path in a network of stocks can help analysts make effective trading strategies.
2. Problem statement: Given a directed graph where each node represents a stock and each edge represents a transaction cost between two stocks, implement a function that returns the shortest path from a start_stock to an end_stock. If no path exists, return -1.
3. Function/class signature:
- def find_shortest_path(graph: Dict[str, List[Tuple[str, int]]], start_stock: str, end_stock: str) -> int:
4. Example 1:
Input: graph = {'A': [('B', 1), ('C', 4)], 'B': [('C', 2), ('D', 5)], 'C': [('D', 1)], 'D': []}, start_stock = 'A', end_stock = 'D'
Output: 4
Explanation: The path A -> B -> C -> D has a transaction cost of 1 + 2 + 1 = 4.
5. Example 2:
Input: graph = {'A': [('B', 5)], 'B': [('C', 3)], 'C': [], 'D': []}, start_stock = 'A', end_stock = 'D'
Output: -1
Explanation: There is no path from A to D.
6. Constraints:
- The graph has at most 1000 stocks.
- The number of transactions (edges) can be at most 10,000.
- Transaction costs are positive integers less than 1000.
- start_stock and end_stock are guaranteed to be valid stock identifiers in the graph.

Related Bloomberg Software Engineer interview prep

Start practicing Bloomberg questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free