← 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 in-memory database design problem. The question kept growing with each layer and I felt like I was always one step behind the requirements.

Questions Asked (3)

Q1

Design and implement an in-memory key-record store where each record maps string fields to integer values. Support set, get, and delete operations, where deleting the last field in a record removes the record entirely.

System DesignData ModelingAlgorithms & Data Structures
Author's notes

The basic CRUD layer felt straightforward and I got through it fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then propose a data model using a hash map of records, where each record is itself a hash map of field-value pairs. Discuss operations, edge cases, and complexity, and consider optimizations like lazy deletion or maintaining a field count.

Pro tip: Demonstrate awareness of real-world concerns such as thread safety and memory management, and mention how you would test the implementation thoroughly, including edge cases like deleting non-existent records.

1. Clarify Requirements

Ask questions to understand expected operations, data sizes, concurrency needs, and persistence requirements. Confirm that deleting the last field removes the record.

2. Design Data Model

Propose a nested hash map structure: an outer map from record keys to inner maps, where inner maps store field-value pairs. Discuss alternatives like using a single map with composite keys.

3. Define Operations

Specify the behavior of set, get, and delete. For set, update or insert the field; for get, retrieve the value or indicate absence; for delete, remove the field and if the record becomes empty, remove the record.

4. Analyze Complexity and Edge Cases

Discuss time and space complexity for each operation. Cover edge cases: deleting non-existent fields/records, setting fields on non-existent records, and handling empty records.

5. Consider Optimizations and Extensions

Mention potential optimizations like lazy deletion, maintaining field counts, or using concurrent data structures for thread safety. Discuss how to extend to support additional operations or persistence.

Key Points to Mention

  • Use a nested hash map (dictionary) structure for efficient O(1) average-case operations.
  • Ensure that deleting the last field in a record removes the record to avoid empty records.
  • Handle edge cases such as deleting non-existent fields or records gracefully.
  • Discuss time and space complexity: O(1) for set, get, delete on average.
  • Consider thread safety if the store will be accessed concurrently, and mention synchronization mechanisms.
  • Mention testing strategies, including unit tests for all operations and edge cases.

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

Q2

Extend the database to track how many times each key has been referenced across all operations, then implement a topN function that returns the N most-accessed keys, breaking ties alphabetically.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

This is where I started slowing down.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: what operations exist, how keys are referenced, and the expected scale. Then propose a data structure that tracks reference counts efficiently, such as a hash map from key to count, and discuss how to maintain a sorted order for topN queries. Finally, outline the algorithm for topN, including tie-breaking, and analyze time and space complexity.

Pro tip: Mention that you would use a min-heap of size N to find top N in O(M log N) time, where M is the number of unique keys, and that tie-breaking alphabetically can be handled by including the key in the heap comparison. Also, discuss whether the counts need to be persisted or can be in-memory, and how to handle concurrent updates if needed.

1. Clarify requirements and constraints

Ask about the operations that reference keys, the expected number of unique keys, the frequency of topN calls, and whether the data needs to be persisted or can be in-memory. Also clarify tie-breaking rules and if N is fixed or variable.

2. Design the data structure for tracking counts

Propose a hash map (dictionary) mapping each key to its reference count. Discuss how to increment counts on each operation, and consider if additional structures are needed for efficient topN queries.

3. Implement the topN function

Describe an algorithm to retrieve the N most-accessed keys. For example, iterate through the hash map and maintain a min-heap of size N based on count, with ties broken alphabetically. Alternatively, sort the keys by count descending and key ascending, then take the first N.

4. Analyze time and space complexity

For the heap approach, time complexity is O(M log N) per topN call, where M is the number of unique keys. Space complexity is O(M) for the hash map and O(N) for the heap. If topN is called frequently, consider maintaining a sorted structure or caching results.

5. Discuss trade-offs and extensions

Compare the heap approach with sorting (O(M log M)) and with maintaining a balanced BST or skip list for O(log M) updates and O(N) retrieval. Mention concurrency, persistence, and scalability considerations for a production system.

Key Points to Mention

  • Use a hash map to track reference counts for O(1) updates.
  • For topN, a min-heap of size N gives O(M log N) time, which is efficient when N is small.
  • Tie-breaking alphabetically can be implemented by comparing keys when counts are equal.
  • If topN is called frequently, consider maintaining a sorted data structure or caching the topN results.
  • Discuss space-time trade-offs: storing counts increases memory usage but enables fast queries.
  • Consider concurrency: if multiple threads update counts, use locks or atomic operations.
  • Mention that the solution should be scalable to millions of keys, so avoid O(M log M) sorting per query if possible.

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

Q3

Add user-aware locking to the database: any user can modify an unlocked key, but once a key is locked by a specific user, only that user can make changes. Implement set, delete, lock, and unlock operations that respect this constraint.

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

The lock semantics tripped me up a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and assumptions, then design a data model that stores lock ownership (e.g., a lock_owner field per key) and define the API semantics for set, delete, lock, and unlock. Walk through the operations with clear rules for authorization, error handling, and concurrency, and discuss trade-offs like atomicity, consistency, and scalability.

Pro tip: Emphasize atomicity and race conditions: locking must be atomic to prevent two users from locking simultaneously, and operations should be idempotent where possible. Also, consider how to handle lock expiration or stale locks to avoid deadlocks in a production system.

1. Clarify requirements and assumptions

Ask about concurrency expectations, persistence, and whether locks should expire. Confirm that lock ownership is per key and that only the owner can modify or unlock.

2. Design data model and API

Define a key-value store where each key has a value and an optional lock owner. Specify the API signatures for set, delete, lock, and unlock, including parameters and return values.

3. Define operation semantics and authorization

For each operation, specify the rules: set/delete allowed if unlocked or if requester is owner; lock allowed only if unlocked; unlock allowed only by owner. Include error responses for unauthorized attempts.

4. Address concurrency and atomicity

Explain how to ensure atomic check-and-set for lock and modify operations, using transactions, compare-and-swap, or distributed locks. Discuss race conditions and how to prevent them.

5. Discuss trade-offs and extensions

Talk about consistency vs availability, lock expiration, scalability, and potential optimizations like caching or sharding. Mention monitoring and failure recovery.

Key Points to Mention

  • Atomicity of lock acquisition and modification to prevent race conditions
  • Authorization checks: only lock owner can modify or unlock
  • Error handling: appropriate HTTP status codes or error types for unauthorized or locked operations
  • Lock expiration or timeout to avoid deadlocks and stale locks
  • Idempotency of operations, especially unlock and delete
  • Scalability considerations: distributed locking, database transactions, or consensus protocols

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