← Coinbase Interview Insights

Coinbase·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Coinbase SWE interview, algorithmic round focused on dynamic programming with a stock trading twist. The follow-up questions about fee variations and concurrent share holdings made it more interesting than your typical DP problem.

Questions Asked (2)

Q1

Given an array of daily stock prices and a transaction fee charged on each sale, find the maximum net profit you can make with unlimited transactions (buy then sell, one share at a time). Walk through your algorithm and give time and space complexity.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The DP formulation clicked pretty fast for me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints and edge cases, then present a dynamic programming solution that tracks the maximum profit with and without holding a stock, incorporating the transaction fee on each sale. Walk through the recurrence relations, provide a concrete example, and analyze time and space complexity.

Pro tip: Mention that the DP can be optimized to O(1) space by keeping only the previous day's states, and discuss how the fee affects the decision to sell versus hold. This shows you consider practical optimizations and trade-offs.

1. Clarify the problem

Confirm that you can buy and sell multiple times, but must sell before buying again, and that the fee is deducted from each sale. Ask about edge cases like empty array or fee larger than any profit.

2. Define states and recurrence

Define two states: cash (max profit with no stock) and hold (max profit while holding a stock). Derive transitions: cash = max(cash, hold + price - fee) and hold = max(hold, cash - price).

3. Walk through an example

Use a small array like [1,3,2,8,4,9] with fee=2 to demonstrate how the states update and yield the maximum profit.

4. Analyze complexity

State that the algorithm runs in O(n) time and O(1) space, as it processes each price once and only stores two variables.

5. Discuss trade-offs and alternatives

Mention that a greedy approach fails due to the fee, and that the DP is optimal. Optionally, discuss how the solution changes if the fee is charged on both buy and sell.

Key Points to Mention

  • Dynamic programming with two states: cash and hold.
  • Recurrence relations: cash = max(cash, hold + price - fee), hold = max(hold, cash - price).
  • Initialization: cash = 0, hold = -infinity (or -price[0]).
  • Time complexity O(n) and space complexity O(1).
  • The fee is applied only on sale, and it affects the sell decision.
  • Edge cases: empty array, single price, fee larger than any profit.

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

Q2

How would your solution change if the commission fee applied to both buying and selling instead of just selling? What if you could hold multiple shares at the same time?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Fee on both sides is basically just adjusting two transitions in the recurrence, not a big structural change.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, restate the original problem and its assumptions to ensure clarity. Then, systematically analyze how each modification affects the problem's constraints and the optimal strategy, discussing algorithmic adjustments and trade-offs. Finally, summarize the impact on time/space complexity and potential edge cases.

Pro tip: Demonstrate awareness that these changes often transform the problem from a simple greedy or DP to a more complex state-based DP, and mention that you would validate with small examples before coding.

1. Clarify the original problem

Briefly restate the original problem, including the commission fee structure (only on selling) and the constraint of holding at most one share at a time.

2. Analyze the first modification: fee on both buy and sell

Explain how adding a fee on buying changes the profit calculation and may affect the decision to buy. Discuss how this impacts the DP recurrence or greedy choice, and whether the optimal strategy shifts.

3. Analyze the second modification: multiple shares

Describe how allowing multiple shares changes the state space. If shares are indistinguishable, it may become a resource allocation problem; if distinguishable (e.g., different prices), it becomes more complex, possibly requiring a different DP or greedy approach.

4. Discuss algorithmic adjustments and trade-offs

Propose specific changes to the algorithm, such as adding a dimension to the DP state or using a priority queue. Compare time and space complexity implications and mention any new edge cases.

5. Summarize and conclude

Recap how each change affects the solution, emphasizing the increased complexity and the need to re-evaluate assumptions. Mention that you would test with examples to ensure correctness.

Key Points to Mention

  • Impact on dynamic programming state definition and transition equations
  • Greedy vs. DP: when each is appropriate and how modifications affect the choice
  • Time and space complexity changes (e.g., from O(n) to O(n*k) for k shares)
  • Edge cases: zero fees, negative profits, multiple shares with different costs
  • Trade-offs between simplicity and optimality when generalizing the problem
  • Real-world relevance: transaction fees and portfolio management in trading systems

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