← Coinbase Interview Insights

Coinbase·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Coinbase software engineer interview with a coding round focused on designing a cursor-based paginator from scratch. The problem had more edge cases than it looked like at first glance and I probably underestimated it going in.

Questions Asked (1)

Q1

Design a pagination system that supports forward and backward navigation using cursors. You're given a sorted array of items and a page size. Implement getFirstPage(), getNextPage(cursor), and getPrevPage(cursor), each running in O(pageSize) time, and handle edge cases like partial last pages and navigating past the boundaries.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

I started by just using an integer index as the cursor which felt almost too simple, and the interviewer kept pushing on whether that was enough.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the cursor design first: it should encode the index of the first item on the current page, enabling O(1) access and O(pageSize) slicing. Then implement each method by computing the start index from the cursor, slicing the array within bounds, and returning the page along with new cursors for next and previous pages. Handle edge cases by checking array bounds and returning empty pages or null cursors when at the ends.

Pro tip: Define the cursor as the index of the first item on the page, not the last, to simplify both forward and backward navigation and avoid off-by-one errors. Also, explicitly state that you assume the array is static; if it can change, you'd need a more robust cursor like a unique ID or timestamp.

1. Clarify requirements and assumptions

Confirm that the array is sorted and static, and that the cursor is an opaque token. Discuss whether the cursor should be index-based or value-based, and how to handle concurrent modifications if any.

2. Design the cursor

Choose a cursor representation that allows O(1) access to the page start. For a static array, using the index of the first item is simple and efficient. Explain how this supports both forward and backward navigation.

3. Implement getFirstPage

Return the first page by slicing the array from index 0 to min(pageSize, array length). Provide a next cursor if there are more items, and a prev cursor as null.

4. Implement getNextPage and getPrevPage

For getNextPage, use the cursor to get the start index, then slice from start to start+pageSize. For getPrevPage, compute the new start as max(0, start - pageSize) and slice accordingly. Return appropriate cursors for further navigation.

5. Handle edge cases and analyze complexity

Check for boundaries: if start >= array length, return empty page; if start < 0, clamp to 0. Ensure each method runs in O(pageSize) time due to slicing, and O(1) extra space. Discuss partial last pages and empty arrays.

Key Points to Mention

  • Cursor design: index of first item on the page for O(1) access and simplicity.
  • Time complexity: O(pageSize) per operation due to array slicing; space complexity O(pageSize) for the returned page.
  • Edge cases: empty array, page size larger than array, navigating before first page or after last page.
  • Return values: each method should return the page items and cursors for next and previous pages (or null if not available).
  • Assumption of static array; if dynamic, consider using a stable identifier or timestamp as cursor.
  • Trade-offs: index-based cursors are simple but break if the array is modified; value-based cursors are more robust but require searching.

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