← Coinbase Interview Insights

Coinbase·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026Remote

Summary

Coinbase software engineer interview with a multi-part coding problem built around a food delivery platform. Three progressively harder parts, each adding new constraints on top of the last. The jump from part 2 to part 3 was steeper than I expected.

Questions Asked (3)

Q1

Given a user's location and a set of restaurants with their menu items and prices, find the restaurant with the lowest total cost for a given basket. If there's a tie on price, return the nearest one. You need to define how you compute distance.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The distance part tripped me up more than the pricing logic.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem: define distance metric (e.g., Euclidean or Manhattan), confirm if basket items are exactly matched or can be substituted, and discuss data scale. Then outline an algorithm: for each restaurant, compute total cost by summing prices of basket items (handle missing items), and compute distance; track the best (lowest cost, then nearest). Finally, analyze time and space complexity, and discuss potential optimizations like pre-filtering by distance or using spatial indexes.

Pro tip: Mention that in a real system, you'd likely precompute distances or use a geospatial index (e.g., geohash) to avoid O(n) distance calculations per query, and consider caching frequent baskets. This shows awareness of production-scale trade-offs.

1. Clarify requirements and assumptions

Ask about distance metric (straight-line vs. road), whether all basket items must be available, and if prices are static. Confirm input/output format and scale.

2. Define distance computation

Choose a metric (e.g., Euclidean for simplicity, Manhattan for grid-like cities) and explain how to compute it from user location to each restaurant. Mention that for large-scale, Haversine is more accurate.

3. Design the algorithm

Iterate through restaurants, compute total cost for the basket (sum item prices, handle missing items), and compute distance. Track the best restaurant based on cost, then distance.

4. Analyze complexity and optimize

State time complexity O(R * B) where R is restaurants and B is basket size, and space O(1). Discuss optimizations like pre-filtering by distance or using a spatial index.

5. Discuss edge cases and trade-offs

Cover missing items, ties, no restaurants available, and trade-offs between accuracy and performance (e.g., Euclidean vs. road distance).

Key Points to Mention

  • Distance metric choice: Euclidean, Manhattan, or Haversine, and when to use each.
  • Handling missing items: either skip restaurant or treat as infinite cost.
  • Tie-breaking logic: if costs equal, compare distances; if distances equal, any deterministic rule.
  • Time complexity: O(R * B) and potential optimizations like spatial indexing or precomputation.
  • Data structures: hash maps for menu items to allow O(1) lookups.
  • Scalability: how to handle large numbers of restaurants or frequent queries (caching, geohashing).

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

Q2

Given a stream of orders with timestamps and per-item prices, compute total revenue, order count, and average order value over a sliding time window. The solution needs to support multiple overlapping windows efficiently.

Algorithms & Data StructuresSystem DesignProduct Analytics & Metrics
Author's notes

I went to a sliding window with a deque pretty fast.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: define the sliding window semantics (e.g., tumbling vs. hopping, event-time vs. processing-time), whether windows are fixed-size or arbitrary, and the expected throughput and latency. Then propose a data structure like a balanced BST or a deque with prefix sums to maintain per-window aggregates, and discuss how to handle multiple overlapping windows efficiently, possibly using a segment tree or a time-indexed ring buffer with incremental updates.

Pro tip: Emphasize the trade-offs between exact and approximate solutions (e.g., using t-digests for percentiles) and mention how you'd handle out-of-order events and late data, as these are critical in financial systems like Coinbase.

1. Clarify Requirements

Ask about window types (fixed vs. sliding, overlapping), time semantics (event-time vs. processing-time), data volume, latency requirements, and whether exact or approximate results are acceptable.

2. Choose Data Structures

Select appropriate structures: a deque for maintaining a single window's orders, a balanced BST or Fenwick tree for prefix sums to compute aggregates over arbitrary ranges, and a segment tree for multiple overlapping windows.

3. Design Algorithm

Outline an incremental algorithm: for each new order, update the relevant windows by adding the order's price and count, and remove expired orders. For multiple windows, use a time-indexed array or tree to query sums over any interval in O(log n).

4. Handle Edge Cases

Address out-of-order events, late data, window boundaries, and empty windows. Discuss watermarks and allowed lateness if using event-time processing.

5. Analyze Complexity & Scalability

Analyze time and space complexity per operation and for multiple windows. Discuss distributed processing (e.g., using Apache Flink or Kafka Streams) if data volume is high.

Key Points to Mention

  • Sliding window semantics: tumbling vs. hopping vs. sliding, and how they affect aggregation
  • Data structures: deque, balanced BST, Fenwick tree (BIT), segment tree for range queries
  • Incremental computation: maintaining running sums and counts to avoid recomputation
  • Handling out-of-order events and late data with watermarks and allowed lateness
  • Time and space complexity: O(1) or O(log n) per update, O(k) for k windows
  • Scalability: distributed stream processing frameworks and partitioning strategies

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

Q3

Within a time window, return the top K orders by total price and the top K items by units sold. The data updates in real time, so the solution needs to handle insertions and recalculations efficiently. Discuss data structures, complexity, and how you handle ties.

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

This was the hardest part.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: define the time window (sliding vs. tumbling), whether K is fixed, and how ties should be broken (e.g., by order ID or timestamp). Then propose a hybrid data structure: a hash map for O(1) updates and a balanced BST or heap for maintaining top K, with careful handling of ties via composite keys. Discuss trade-offs between exact and approximate solutions, and how to handle real-time updates efficiently.

Pro tip: Mention that ties can be broken deterministically by including a unique identifier (like order ID) in the sort key, ensuring stable and reproducible results. Also, consider using a min-heap of size K for top K queries to achieve O(log K) updates, which is efficient for large streams.

1. Clarify Requirements and Constraints

Ask about the time window semantics (sliding vs. tumbling), whether K is fixed, expected data volume, and tie-breaking rules. Confirm if approximate results are acceptable.

2. Choose Data Structures

Propose a hash map for O(1) access to order/item totals, and a balanced BST or min-heap of size K for maintaining top K. For ties, use composite keys (e.g., total price + order ID).

3. Handle Real-Time Updates

On each insertion, update the hash map and adjust the top-K structure. For sliding windows, use a time-ordered queue to expire old entries and update aggregates accordingly.

4. Analyze Complexity

State time complexity: O(1) average for hash map updates, O(log K) for heap/BST adjustments. Space: O(N) for hash map and O(K) for top-K structure. Discuss trade-offs with alternative approaches.

5. Address Ties and Edge Cases

Explain tie-breaking strategy (e.g., by order ID or timestamp) and how to handle empty windows, K larger than data size, and concurrent updates.

Key Points to Mention

  • Use of hash map for O(1) updates to running totals
  • Min-heap of size K for efficient top-K maintenance (O(log K) per update)
  • Composite keys for deterministic tie-breaking (e.g., total + ID)
  • Sliding window implementation with a time-ordered queue for expirations
  • Trade-offs between exact and approximate algorithms (e.g., count-min sketch)
  • Complexity analysis and scalability considerations for real-time systems

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