← Coinbase Interview Insights

Coinbase·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026Remote

Summary

Coinbase software engineer interview that leaned heavily on pagination design. The question seemed simple at first but kept branching into tradeoffs I hadn't fully thought through beforehand.

Questions Asked (1)

Q1

Given a list or stream of items and pagination parameters like page number, page size, and an optional sort key, implement a function that returns the correct page of results. Be ready to discuss 0-indexed vs 1-indexed pages, out-of-range handling, returning total count and total pages, and the difference between offset-based and cursor/keyset-based pagination at scale.

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

I started with the basic slice logic and felt fine, then they asked about out-of-range pages and I fumbled a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: indexing convention, out-of-range behavior, and whether total count is needed. Then implement a clean offset-based pagination function with validation, and discuss how to extend to cursor-based pagination for scale, highlighting trade-offs.

Pro tip: Explicitly state your assumptions about indexing and out-of-range behavior before coding, and mention that in production you'd use cursor-based pagination for large datasets to avoid offset performance issues.

1. Clarify requirements and edge cases

Ask about indexing (0 vs 1), page size limits, out-of-range handling, and whether total count/pages are required. Confirm sort key behavior and stability.

2. Design the function signature and validation

Define input parameters (list/stream, page, size, sort key) and output (page items, total count, total pages). Add validation for negative or zero page/size.

3. Implement offset-based pagination

Compute start index as (page - 1) * size for 1-indexed, or page * size for 0-indexed. Slice the list, handle out-of-range by returning empty list or error, and compute total pages.

4. Discuss cursor-based pagination and trade-offs

Explain that offset pagination is simple but inefficient for large offsets and unstable with inserts/deletes. Cursor-based uses a unique sort key (e.g., timestamp+id) to fetch next page efficiently.

5. Summarize and test with examples

Walk through edge cases (first page, last page, out-of-range, empty list) and mention testing strategy. Conclude with when to use each pagination type.

Key Points to Mention

  • 0-indexed vs 1-indexed pages: clarify and handle conversion correctly.
  • Out-of-range handling: return empty list, error, or clamp to last page.
  • Total count and total pages: compute using ceiling division, and note performance cost of counting.
  • Offset-based pagination: simple but O(offset) and unstable with concurrent writes.
  • Cursor/keyset-based pagination: efficient for large datasets, uses a unique sort key, stable under inserts/deletes.
  • Sort key stability: ensure deterministic ordering by including a tiebreaker (e.g., ID) when sorting.

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