← Coinbase Interview Insights

Coinbase·Software Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Coinbase software engineer interview that went deep on extending a toy bank system. The problem starts simple enough but the follow-up questions about scheduling and cancellation are where things get interesting.

Questions Asked (4)

Q1

You're given an in-memory bank system with basic operations already implemented. Extend it to support scheduled transfers: a way to queue a transfer for a future timestamp, and a way to cancel one that hasn't fired yet. Walk through your design.

System DesignAlgorithms & Data StructuresData Modeling
Author's notes

The core part wasn't bad.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then propose a design using a priority queue (min-heap) for efficient retrieval of due transfers and a hash map for O(1) cancellation. Walk through the data model, operations, and edge cases, and discuss trade-offs and potential improvements.

Pro tip: Mention that you would use a lazy deletion approach for cancellation to avoid O(n) removal from the heap, and discuss how to handle concurrency if the system is multi-threaded.

1. Clarify Requirements

Ask about expected scale, concurrency, persistence, and whether transfers should execute exactly once. Confirm that the system is in-memory and that we need to support scheduling and cancellation.

2. Design Data Model

Propose a ScheduledTransfer class with fields like id, fromAccount, toAccount, amount, executeAt, and status. Use a min-heap keyed by executeAt for efficient retrieval of due transfers, and a hash map from transfer ID to transfer object for O(1) lookup.

3. Implement Core Operations

For scheduling, create a transfer, add it to the heap and map. For cancellation, mark the transfer as cancelled in the map (lazy deletion) and optionally remove from heap if needed. For execution, a background thread or scheduler pops due transfers from the heap, checks if cancelled, and executes if valid.

4. Handle Edge Cases and Concurrency

Discuss handling of insufficient funds at execution time, duplicate cancellations, and thread safety using locks or concurrent data structures. Consider using a scheduler like ScheduledExecutorService or a custom timer.

5. Discuss Trade-offs and Extensions

Compare heap vs. sorted list vs. timing wheel for performance. Mention persistence, distributed scheduling, and idempotency as potential extensions. Highlight time and space complexity of operations.

Key Points to Mention

  • Use a min-heap (priority queue) ordered by execution timestamp for O(log n) insertion and O(1) peek of next due transfer.
  • Use a hash map (dictionary) from transfer ID to transfer object for O(1) cancellation and status lookup.
  • Implement lazy deletion: when cancelling, mark the transfer as cancelled in the map; when popping from heap, skip if cancelled.
  • Ensure thread safety with locks or concurrent data structures if multiple threads access the scheduler.
  • Handle edge cases: insufficient funds at execution time, duplicate cancellations, and transfers scheduled in the past.
  • Discuss time complexity: O(log n) for scheduling, O(1) for cancellation (amortized), and O(log n) for execution (popping from heap).

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

Q2

What happens if the source account doesn't have enough funds at the time the scheduled transfer actually executes?

System DesignTechnical Trade-offs
Author's notes

I said fail silently and log it, then moved on.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints of the scheduled transfer system, then walk through the possible failure scenarios and how to handle them gracefully. Emphasize the importance of idempotency, atomicity, and clear communication to the user, and discuss trade-offs between different approaches.

Pro tip: Demonstrate awareness of financial regulations and the need for auditability; mention that you would log every attempt and outcome for compliance and debugging. Also, consider proactive measures like pre-authorization or balance checks at scheduling time to reduce failures.

1. Clarify Requirements and Assumptions

Ask questions to understand the system's expectations: Is the transfer guaranteed? What are the SLAs? Are there retries? This shows you don't jump to solutions without context.

2. Identify Failure Modes and Edge Cases

Enumerate scenarios: insufficient funds at execution, account closed, currency mismatch, etc. Consider both technical and business implications.

3. Design Handling Strategy

Propose a robust approach: check balance at execution, fail the transfer atomically, notify the user, and possibly retry or reschedule based on policy. Discuss idempotency to avoid double-spending.

4. Discuss Trade-offs and Alternatives

Compare options: immediate failure vs. retry with backoff, reserving funds at scheduling time vs. checking at execution. Highlight pros and cons regarding user experience, system load, and consistency.

5. Address Monitoring and Compliance

Explain how you would log, monitor, and alert on such failures. Mention audit trails and regulatory requirements, especially in fintech.

Key Points to Mention

  • Idempotency: Ensure that retries or duplicate execution attempts don't result in multiple transfers.
  • Atomicity: The balance check and transfer should be atomic to prevent race conditions.
  • User notification: Inform the user promptly about the failure and next steps.
  • Retry policies: Consider exponential backoff, maximum retries, and dead-letter queues.
  • Reservation of funds: Optionally reserve funds at scheduling time to guarantee availability.
  • Audit logging: Maintain detailed logs for compliance and debugging.

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

Q3

How do you handle calling cancelScheduled on a transfer that has already executed?

API & IntegrationsTechnical Trade-offs
Author's notes

Pretty short exchange.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Acknowledge that cancelScheduled on an already executed transfer is a race condition and should be handled idempotently. Explain that the API should return a clear error or success response indicating the transfer is already executed, and discuss how to design the system to prevent such calls or handle them gracefully.

Pro tip: Emphasize the importance of idempotency and clear error semantics to avoid duplicate transfers or inconsistent states. Mention that logging such attempts can help detect client bugs or malicious behavior.

1. Identify the scenario

Recognize that the transfer has already executed, so cancellation is no longer possible. This is a race condition between scheduling and execution.

2. Define expected behavior

Decide on the API response: return an error (e.g., 409 Conflict) or a success with a message indicating the transfer is already executed. Ensure idempotency to avoid side effects.

3. Implement server-side handling

In the cancelScheduled endpoint, check the transfer status. If executed, return the appropriate response without altering the transfer. Use database transactions or locks to prevent race conditions.

4. Communicate with clients

Document the behavior clearly so clients know how to handle the response. Provide error codes and messages that are actionable.

5. Monitor and log

Log occurrences to detect patterns, such as clients repeatedly trying to cancel executed transfers, which may indicate a bug or misunderstanding.

Key Points to Mention

  • Idempotency: ensure that repeated cancel requests do not cause unintended effects.
  • Race conditions: use locking or atomic operations to handle concurrent execution and cancellation.
  • Error handling: return appropriate HTTP status codes (e.g., 409 Conflict) and clear error messages.
  • API design: consider making cancelScheduled a no-op if already executed, or return a specific error.
  • Client communication: document the behavior and provide guidance on handling the response.
  • Monitoring: log attempts to cancel executed transfers to identify client issues.

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

Q4

How do you ensure tick is idempotent, meaning calling it multiple times with the same timestamp doesn't re-apply transfers?

System DesignAlgorithms & Data Structures
Author's notes

Blanked for a second here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the context: what 'tick' represents (e.g., a periodic job processing transfers) and why idempotency matters (avoiding duplicate transfers on retries). Then propose a strategy using idempotency keys derived from the timestamp and transfer details, combined with a persistent store to track processed ticks, ensuring that re-processing the same timestamp is a no-op.

Pro tip: Emphasize that idempotency must be enforced at the data layer (e.g., unique constraints or conditional writes) to handle concurrent executions, not just in application logic. Also, mention that timestamps alone may not be unique; include a unique identifier for the tick or use a composite key.

1. Clarify the problem

Ask questions to understand what 'tick' does, the source of timestamps, and the expected behavior on duplicate calls. Confirm that idempotency means no side effects on repeated calls with the same timestamp.

2. Design an idempotency key

Propose deriving a unique key from the timestamp and other relevant identifiers (e.g., transfer ID, account ID) to uniquely identify the operation. Consider using a hash or composite key.

3. Persist processed keys

Store the idempotency key in a durable, transactional store (e.g., database) with a unique constraint. Before processing, attempt to insert the key; if it already exists, skip processing.

4. Handle concurrency and failures

Use atomic operations (e.g., INSERT ... ON CONFLICT DO NOTHING) to handle concurrent ticks. Ensure that the key is stored only after successful processing, or use a two-phase approach with status tracking.

5. Test and monitor

Describe how to test idempotency (e.g., simulate duplicate calls) and monitor for duplicate processing attempts. Discuss cleanup of old keys to avoid unbounded growth.

Key Points to Mention

  • Idempotency key derived from timestamp and transfer details
  • Unique constraint or conditional write in a database
  • Atomic operations to handle concurrent ticks
  • Two-phase commit or status tracking to avoid partial processing
  • Cleanup or TTL for idempotency keys to manage storage
  • Testing strategies: unit tests, integration tests, and chaos engineering

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