← Coinbase Interview InsightsSoftware Engineer

Coinbase·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Coinbase software engineer interview that focused entirely on pagination, which sounds boring until you're 20 minutes deep explaining cursor-based vs offset-based tradeoffs and realizing you never actually thought hard about this before.

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 scaling differences between offset-based and cursor/keyset-based pagination.

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

Started fine with the basic slice logic but then they kept pulling the thread.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: indexing convention, out-of-range behavior, and whether to return total count/pages. Then implement a clean offset-based pagination function with validation and optional sorting, and discuss the trade-offs with cursor-based pagination for scalability.

Pro tip: Explicitly state your indexing convention and handle out-of-range pages by returning an empty list with a clear message or error, rather than throwing an unhandled exception. Also, mention that for large datasets, cursor-based pagination is preferred to avoid performance degradation with high offsets.

1. Clarify Requirements

Ask about indexing (0 vs 1), out-of-range behavior (empty list, error, or clamp), and whether to return metadata like total count and total pages. Confirm if sorting is required and how to handle ties.

2. Design the Function Signature

Define parameters: items (list or stream), page number, page size, optional sort key, and sort order. Decide on return type: a page of items and optionally metadata.

3. Implement Offset-Based Pagination

Validate inputs (page >= 0 or 1, page size > 0). Sort if needed. Compute start index = (page - offset) * page_size. Slice the list safely, handling out-of-range by returning empty list. Compute total count and total pages if required.

4. Discuss Edge Cases and Trade-offs

Cover 0-indexed vs 1-indexed, out-of-range pages, empty results, and performance. Explain that offset-based pagination is simple but inefficient for large offsets (O(n) skip) and unstable with inserts/deletes, while cursor-based pagination is more scalable and consistent.

5. Summarize and Recommend

Conclude with when to use each approach: offset-based for small datasets or UI with page numbers, cursor-based for large, dynamic datasets like feeds. Mention that Coinbase likely deals with high-volume data, so cursor-based is often preferred.

Key Points to Mention

  • 0-indexed vs 1-indexed pages: clarify and document the convention.
  • Out-of-range handling: return empty list or error, avoid exceptions.
  • Returning total count and total pages: compute from total items and page size.
  • Offset-based pagination: simple but O(offset) skip and unstable with concurrent modifications.
  • Cursor/keyset-based pagination: uses a unique, sequential key to fetch next page efficiently, stable under inserts/deletes.
  • Scalability: offset-based degrades with large offsets; cursor-based is O(1) per page and better for infinite scroll or real-time data.

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