← Coinbase Interview Insights

Coinbase·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Coinbase SWE interview with a coding problem that had a specific constraint I wasn't expecting. The twist on the standard knapsack setup threw me off a bit.

Questions Asked (1)

Q1

You have N transactions, each with an ID, a size, and a fee. Given a block with a fixed size capacity, choose which transactions to include in order to maximize the total fee collected.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Looked like a classic knapsack at first and I started mentally reaching for a heap-based approach.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize this as the 0/1 Knapsack problem and clearly state that it can be solved optimally with dynamic programming in O(N * capacity) time and space. Then discuss the trade-offs: for large N and capacity, DP may be infeasible, so consider greedy heuristics or approximation algorithms, and mention that in practice, block space is limited and transactions have additional constraints like dependencies.

Pro tip: Coinbase values production-ready thinking: mention that in real blockchain systems, transaction selection often uses a greedy fee-rate (fee per byte) heuristic due to time constraints, and that the optimal DP solution is a good benchmark but may not be practical for large mempools.

1. Clarify the problem

Restate the problem to ensure understanding: we need to select a subset of transactions to maximize total fee without exceeding block size capacity. Ask if transactions can be partially included (no, they are indivisible) and if there are any other constraints (e.g., dependencies).

2. Identify the algorithmic pattern

Recognize this as the 0/1 Knapsack problem, where each transaction is an item with weight (size) and value (fee), and the block capacity is the knapsack capacity. State that it is NP-hard but solvable in pseudo-polynomial time with DP.

3. Present the DP solution

Explain the DP approach: create a table dp[i][w] representing max fee using first i transactions with capacity w. Recurrence: dp[i][w] = max(dp[i-1][w], dp[i-1][w - size_i] + fee_i) if size_i <= w. Time and space O(N * capacity).

4. Discuss trade-offs and alternatives

For large N and capacity, DP may be too slow or memory-heavy. Mention greedy by fee/size ratio as a fast heuristic (not always optimal) and approximation schemes (FPTAS) if needed. Also note that in practice, block space is limited and transactions may have dependencies, making it a more complex scheduling problem.

5. Consider real-world context

Relate to Coinbase's domain: in blockchain, transaction selection often uses a greedy fee-rate approach due to real-time constraints. Mention that the optimal DP solution is a good benchmark but may not be used in production for large mempools.

Key Points to Mention

  • 0/1 Knapsack problem reduction
  • Dynamic programming solution with O(N * capacity) time and space
  • Greedy heuristic by fee-to-size ratio (not always optimal)
  • Trade-offs: optimality vs. scalability
  • Real-world constraints: time limits, mempool size, transaction dependencies
  • Approximation algorithms (e.g., FPTAS) for large inputs

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