← Bloomberg Interview Insights

Bloomberg·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Bloomberg coding round, got a subway tracking design problem. Pretty clean problem once you figure out the right data structures to hold the state.

Questions Asked (1)

Q1

Design an UndergroundSystem class that tracks customer check-ins and check-outs at subway stations and can return the average travel time between any two stations.

Algorithms & Data StructuresSystem Design
Author's notes

My first instinct was to just store everything in one big map and figure it out later, which was the wrong move.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the requirements and constraints, then design two hash maps: one to track active check-ins (customer ID to start station and time) and another to aggregate travel data (start and end station pair to total time and trip count). Implement checkIn, checkOut, and getAverageTime methods with O(1) time complexity, and discuss potential edge cases and scalability.

Pro tip: Emphasize that the average should be computed on demand from aggregated totals rather than storing individual trips, which saves memory and speeds up queries. Also, mention that using a composite key (e.g., start + '->' + end) simplifies the aggregation map.

1. Clarify Requirements and Constraints

Ask about expected data volume, concurrency, and whether times are integers or floats. Confirm that check-in/check-out are paired and that average is computed over all completed trips between two stations.

2. Design Data Structures

Use a hash map to store active check-ins keyed by customer ID, and another hash map to store aggregated travel data keyed by a composite of start and end stations. Each entry in the aggregation map holds total time and trip count.

3. Implement Core Methods

For checkIn, record the start station and time. For checkOut, retrieve the check-in, compute the duration, update the aggregation map, and remove the check-in. For getAverageTime, compute total time divided by trip count.

4. Analyze Complexity and Edge Cases

All operations are O(1) time and O(N) space where N is the number of active check-ins plus station pairs. Discuss handling of invalid check-outs, duplicate check-ins, and concurrent access if needed.

5. Discuss Scalability and Extensions

Mention how the design could be extended for distributed systems, e.g., sharding by station or using a database, and how to handle real-time analytics or large-scale data.

Key Points to Mention

  • Use of two hash maps: one for active check-ins and one for aggregated travel data.
  • Composite key for station pairs to efficiently aggregate total time and trip count.
  • O(1) time complexity for all operations.
  • Edge cases: invalid check-outs, duplicate check-ins, and concurrent access.
  • Scalability considerations: sharding, distributed storage, and real-time analytics.
  • Memory optimization by storing aggregates instead of individual trips.

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