← Coinbase Interview Insights

Coinbase·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jul 2026

Summary

Two-part coding interview for a Software Engineer role at Coinbase. First problem was grid pathfinding with a BFS/bitmask twist, second was an event processing design question with idempotency requirements. Pretty dense for a single session.

Questions Asked (5)

Q1

Given a 2D grid representing a restaurant with a starting position, empty cells, obstacles, and food items, find the shortest path from the start to a single specified food cell. Return -1 if unreachable.

Algorithms & Data Structures
Author's notes

Classic BFS, nothing tricky here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the grid as a graph where each cell is a node and edges connect adjacent non-obstacle cells. Use BFS from the start to compute the shortest path to the target food cell, returning the distance or -1 if unreachable.

Pro tip: Clarify assumptions upfront: whether diagonal moves are allowed, if multiple foods exist, and if the grid can be modified. This shows attention to detail and prevents misalignment with the interviewer.

1. Clarify the problem

Ask about movement rules (4-directional vs. 8-directional), grid size limits, and whether the start or food can be on obstacles. Confirm the return value for unreachable cases.

2. Choose BFS for shortest path

Explain that BFS is optimal for unweighted grids because it explores level by level, guaranteeing the shortest path. Mention that DFS would not guarantee shortest path.

3. Outline BFS algorithm

Initialize a queue with the start cell and a visited set. While the queue is not empty, dequeue a cell, check if it's the target, and enqueue all valid unvisited neighbors.

4. Handle edge cases and complexity

Discuss handling of invalid start/target, obstacles, and grid boundaries. State time and space complexity: O(R*C) for both, where R and C are grid dimensions.

5. Test with examples

Walk through a small example to verify the algorithm, including a case where the target is unreachable, and confirm the output.

Key Points to Mention

  • BFS guarantees shortest path in unweighted graphs
  • Use a queue for BFS and a visited set to avoid cycles
  • Time and space complexity: O(R*C)
  • Handle edge cases: start or target on obstacle, out-of-bounds, unreachable target
  • Clarify movement rules (4-directional vs. 8-directional)
  • Potential optimization: bidirectional BFS if grid is large

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

Q2

Extend the grid problem: now there are up to 12 food items and the waiter must collect all of them starting from S, in any order, minimizing total steps. Describe your algorithm, its complexity, and implement it.

Algorithms & Data Structures
Author's notes

This is where I slowed down.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a shortest path on a state space where each state is (current position, set of collected food items). Use BFS to compute distances between all points of interest (start and food items), then apply dynamic programming (TSP-style) to find the optimal order to collect all food items. The complexity is O((F+1)^2 * 2^F) where F is the number of food items (≤12).

Pro tip: Emphasize that BFS on the grid gives unweighted shortest paths, and the DP over subsets is feasible because F ≤ 12, making 2^F manageable. Also, mention that you can optimize by precomputing distances only between points of interest, not the entire grid.

1. Identify points of interest and precompute distances

Treat the start S and each food item as nodes. Run BFS from each node to compute the shortest distance to every other node, considering only walkable cells.

2. Define DP state and base case

Let dp[mask][i] be the minimum steps to collect the set of food items represented by mask and end at food item i. Initialize dp[1<<i][i] = dist[S][i] for each food i.

3. Transition and compute DP

For each mask and last food i, try adding an uncollected food j: dp[mask | (1<<j)][j] = min(dp[mask][i] + dist[i][j]). Iterate masks in increasing order.

4. Extract answer and analyze complexity

The answer is min over i of dp[(1<<F)-1][i]. Time complexity: O(F * 2^F * F) = O(F^2 * 2^F) for DP, plus BFS: O(F * R*C). Space: O(2^F * F) for DP.

5. Implement and test

Write code for BFS and DP, ensuring correct handling of unreachable food items (return -1 or infinity). Test with small cases and edge cases like no food items.

Key Points to Mention

  • BFS for unweighted shortest paths on grid
  • State space: (position, collected food mask)
  • Dynamic programming over subsets (TSP-style)
  • Time complexity: O(F^2 * 2^F + F * R*C)
  • Space complexity: O(2^F * F + R*C)
  • Handling unreachable food items and edge cases

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

Q3

Design and implement a function that processes a stream of order events (NEW, FILL, CANCEL) and returns the final state of each order, including total quantity and filled quantity.

System DesignData Modeling
Author's notes

Felt more like a system design question dressed up as a coding one.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and assumptions, then outline a data model and processing logic. Discuss trade-offs and edge cases, and finally sketch a scalable implementation.

Pro tip: Emphasize idempotency and exactly-once processing, as financial systems require handling duplicate or out-of-order events reliably.

1. Clarify Requirements

Ask about event ordering, duplicate handling, and expected scale to define the problem scope.

2. Design Data Model

Define an Order struct with fields like order_id, total_quantity, filled_quantity, and status.

3. Outline Processing Logic

Describe how to update order state based on event type: NEW creates order, FILL increments filled_quantity, CANCEL marks as cancelled.

4. Address Edge Cases

Discuss handling of duplicate events, out-of-order events, partial fills, and cancellations after fills.

5. Discuss Scalability

Mention partitioning by order_id, using in-memory state with persistence, and potential for distributed processing.

Key Points to Mention

  • Idempotency: ensure duplicate events don't corrupt state
  • Event ordering: handle out-of-order events with sequence numbers or timestamps
  • Data structures: use hash map for O(1) order lookup
  • Concurrency: consider thread-safety if processing in parallel
  • Persistence: checkpoint state for fault tolerance
  • Validation: check for invalid events (e.g., fill exceeding total quantity)

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

Q4

How do you guarantee idempotency in the event processor when the same logical event (same eventId) can arrive multiple times due to at-least-once delivery?

System DesignTechnical Trade-offs
Author's notes

Kept a set of seen eventIds and skipped any event whose id was already in it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the delivery semantics and the need for idempotency, then propose a deduplication mechanism using a persistent store keyed by eventId, and discuss trade-offs like storage cost, latency, and failure scenarios. Emphasize that idempotency should be enforced at the processing layer, not just at the ingestion layer.

Pro tip: Mention that you would also consider idempotent side effects (e.g., using upserts or conditional writes) to handle cases where deduplication fails, and highlight the importance of monitoring duplicate rates to detect issues early.

1. Clarify requirements and constraints

Ask about the expected duplicate rate, latency requirements, and whether the event processor is stateful or stateless. This shows you understand the problem context before jumping to solutions.

2. Choose a deduplication strategy

Propose using a persistent store (e.g., Redis, DynamoDB) to track processed eventIds with a TTL. Discuss alternatives like in-memory caches (risky for distributed systems) or database unique constraints.

3. Design the processing flow

Outline a flow: check if eventId exists in the store; if not, process the event and atomically record the eventId. Ensure atomicity using transactions or conditional writes to avoid race conditions.

4. Address failure scenarios

Explain what happens if the store is unavailable or if the process crashes after processing but before recording. Suggest idempotent side effects (e.g., upserts) and retry mechanisms with exponential backoff.

5. Discuss trade-offs and optimizations

Cover storage cost vs. deduplication window, latency impact, and scalability. Mention partitioning by eventId to distribute load and using bloom filters for memory efficiency if appropriate.

Key Points to Mention

  • At-least-once delivery implies duplicates, so idempotency is essential.
  • Use a unique identifier (eventId) and a persistent deduplication store with TTL.
  • Atomic check-and-set operations to prevent race conditions.
  • Idempotent side effects (e.g., upserts, conditional writes) as a fallback.
  • Trade-offs: storage cost, latency, and deduplication window.
  • Monitoring and alerting on duplicate rates to detect issues.

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

Q5

What are the time and space complexities of your event processing solution in terms of number of events and number of distinct orders?

Algorithms & Data Structures
Author's notes

O(E) time, O(E + O) space where E is events and O is distinct orders.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clearly define the variables: let N be the number of events and M be the number of distinct orders. Then, walk through your solution's data structures and algorithms, deriving time and space complexities in terms of N and M, and explain how they scale. Finally, discuss any trade-offs or optimizations you considered.

Pro tip: Explicitly state the assumptions about the input (e.g., events are streamed or batched, order IDs are unique) because they affect the complexity analysis. Also, mention that in practice, M is often much smaller than N, so focusing on N is key.

1. Define variables and assumptions

State that N is the number of events and M is the number of distinct orders. Clarify whether events are processed in a stream or in batch, and whether order IDs are unique.

2. Describe the data structures used

Explain the key data structures (e.g., hash map for order state, queue for events) and how they store data relative to N and M.

3. Analyze time complexity

Break down the time complexity per event and overall. For example, O(1) per event for hash map updates, leading to O(N) total time, and mention any operations that depend on M.

4. Analyze space complexity

Determine the space used by data structures. For example, O(M) for storing order states and O(N) if storing all events, or O(1) extra if streaming.

5. Discuss trade-offs and optimizations

Mention any trade-offs (e.g., time vs. space) and potential optimizations, such as using more efficient data structures or parallel processing.

Key Points to Mention

  • Time complexity per event and total time complexity in terms of N and M.
  • Space complexity for storing order states and any event buffers.
  • Impact of data structures like hash maps (O(1) average access) and heaps (O(log M) operations).
  • Assumptions about input (e.g., streaming vs. batch, uniqueness of order IDs).
  • Trade-offs between time and space, and potential optimizations.
  • Scalability considerations for large N and M, and how the solution handles them.

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