Bloomberg software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
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)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...
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_executions(records: list[dict[str, str]]). The concrete return type is up to the candidate; the JSON below defines its observable contents.{"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"}]}[{"id":"a","rules":["CITY_CONFLICT"]},{"id":"b","rules":["AMOUNT_LIMIT","CITY_CONFLICT"]},{"id":"c","rules":[]},{"id":"d","rules":[]},{"id":"e","rules":[]}]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 policiesevaluate_executions(records: list[dict[str, str]], desk_rules: list[dict[str, str]] | None = None) without replacing the Part 1 rules.name, window_minutes, and cap_usd.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.cap_usd. This does not automatically flag other members of its window; each execution is evaluated at its own timestamp.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.{"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"}]}{"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"}]}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:{"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"}]}{"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"}]}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:O(n log n + kn + k log k) time for n executions and k desk rules.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 signatureSea.has_ships(top_right: tuple[int, int], bottom_left: tuple[int, int]) -> boolcount_ships(sea: Sea, top_right: tuple[int, int], bottom_left: tuple[int, int]) -> int(x, y).Example 1:[(1, 1), (2, 2), (3, 3), (8, 8)]; top_right = (4, 4); bottom_left = (1, 1).3(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.[(0, 0), (5, 0), (5, 5)]; top_right = (5, 0); bottom_left = (1, 0).1(5, 0), excludes (0, 0), and does not include (5, 5).[0, 1000].bottom_left.x <= top_right.x and bottom_left.y <= top_right.y.0 and 10 ships in the entire domain, with no duplicate locations.count_ships may make at most 400 API calls.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.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:
k = 2, prices = [2, 4, 1, 7, 5] 7 k = 1, prices = [3, 2, 6, 5, 0, 3] 4 1 <= k <= 100 0 <= prices.length <= 1000 0 <= prices[i] <= 1000 Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free