← Coinbase Interview Insights

Coinbase·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Coinbase software engineer interview with two algorithmic parts back to back. Started straightforward and then got progressively weirder with the dependency graph twist. Came out of it unsure if I nailed the pruning discussion or just rambled.

Questions Asked (2)

Q1

Given a sequence of N blocks each with a positive integer value, select a subset to maximize total value such that no two adjacent blocks can both be selected. Implement an efficient solution and analyze its complexity.

Algorithms & Data Structures
Author's notes

Classic house robber variant.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize this as the classic 'House Robber' dynamic programming problem. Define dp[i] as the maximum sum using the first i blocks, with recurrence dp[i] = max(dp[i-1], dp[i-2] + value[i]). Implement iteratively with O(N) time and O(1) space, then analyze complexity and discuss edge cases.

Pro tip: Start by clarifying the problem constraints (e.g., N can be large, values positive) and then walk through a small example to validate your recurrence before coding. This shows structured thinking and catches off-by-one errors early.

1. Clarify and Restate

Confirm the problem: select non-adjacent blocks to maximize sum. Ask about constraints (N size, value range) and edge cases (N=0, N=1).

2. Define DP State and Recurrence

Let dp[i] be the max sum for first i blocks. Recurrence: dp[i] = max(dp[i-1], dp[i-2] + value[i]). Explain why this covers all cases.

3. Optimize Space

Since dp[i] depends only on dp[i-1] and dp[i-2], use two variables to achieve O(1) space. Show how to update them iteratively.

4. Implement and Test

Write clean code with clear variable names. Test with small examples (e.g., [3,2,5,10,7]) and edge cases (empty, single element).

5. Analyze Complexity

State time complexity O(N) and space O(1). Discuss why this is optimal (must examine each element at least once).

Key Points to Mention

  • Dynamic programming approach with optimal substructure and overlapping subproblems
  • Recurrence relation: dp[i] = max(dp[i-1], dp[i-2] + value[i])
  • Space optimization from O(N) to O(1) using two variables
  • Time complexity O(N) and space complexity O(1)
  • Edge cases: empty array, single element, all positive values
  • Alternative: top-down memoization (but iterative is more efficient)

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

Q2

Now add dependency constraints to the block selection problem: a directed edge from u to v means block v can only be selected if block u is also selected. The no-adjacent-blocks rule still applies. The dependencies form a DAG. Solve via backtracking with pruning, and discuss when DP over topological order is sufficient versus when full backtracking is necessary.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where things got messy for me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, model the problem as selecting a subset of blocks that satisfies two constraints: no two selected blocks are adjacent, and if a block is selected, all its ancestors in the dependency DAG must also be selected. Then design a backtracking algorithm that builds the selection incrementally, pruning branches that violate either constraint, and analyze when a DP over topological order can replace backtracking by exploiting the DAG structure and the no-adjacent rule.

Pro tip: Emphasize that the no-adjacent rule introduces local conflicts that break the optimal substructure needed for simple DP, so full backtracking is often necessary; however, if the DAG is a tree or has bounded width, DP over topological order with state capturing the last selected block can be sufficient.

1. Clarify constraints and objective

Confirm whether the goal is to maximize the number of selected blocks, their total weight, or just find any valid selection. Restate the two constraints: no adjacent blocks and dependency closure (if v selected, all ancestors of v selected).

2. Design backtracking with pruning

Process blocks in a fixed order (e.g., topological order). At each step, decide whether to include the current block. Prune if including it violates no-adjacent (neighbor already selected) or if its dependencies are not yet satisfied. Also prune if excluding it makes it impossible to satisfy dependencies of later blocks.

3. Analyze complexity and pruning effectiveness

Discuss worst-case exponential time, but note that pruning can drastically reduce the search space. Mention that dependency constraints force certain blocks to be selected together, which can be exploited to merge nodes or reduce branching.

4. Identify when DP over topological order suffices

DP works when the state can be summarized compactly, e.g., if the DAG is a tree and we only need to track whether the parent is selected. More generally, if the graph has bounded treewidth, DP with state representing the selection status of a separator set can be used.

5. Compare and conclude

Conclude that full backtracking is necessary when the DAG is arbitrary and the no-adjacent rule creates long-range interactions that cannot be captured by a small state. DP is sufficient for structured graphs (trees, bounded treewidth) or when the objective allows decomposition.

Key Points to Mention

  • Dependency closure: selecting a block requires selecting all its ancestors in the DAG.
  • No-adjacent constraint applies to the original block adjacency (e.g., grid or path), not the DAG edges.
  • Backtracking with pruning: use topological order to ensure dependencies are considered before dependents.
  • Pruning strategies: check adjacency conflicts and dependency satisfaction; also use feasibility checks for remaining blocks.
  • DP over topological order: state must capture enough information to enforce both constraints, often including the selection status of recent blocks or a separator.
  • When DP fails: arbitrary DAGs with cycles in the adjacency graph (if blocks are arranged in a graph) or high treewidth make state explosion likely, necessitating backtracking.

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