PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Coinbase

Paginate forward and backward through results

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of pagination mechanics, cursor/token design, array indexing, and state management for bidirectional (forward and backward) navigation.

  • medium
  • Coinbase
  • Coding & Algorithms
  • Software Engineer

Paginate forward and backward through results

Company: Coinbase

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are asked to extend a basic pagination system to support **forward** and **backward** navigation, similar to a cursor-based API. You are given: - A zero-indexed array of items `items` sorted in a fixed, deterministic order. - An integer `pageSize > 0`. Design a paginator with the following operations: 1. `getFirstPage()` → returns the first `pageSize` items and a **cursor** representing the position after the last returned item. 2. `getNextPage(cursor)` → given a cursor returned by a previous call, return the next `pageSize` items and a new cursor. If there are no more items, return an empty list and a special "end" cursor. 3. `getPrevPage(cursor)` → given a cursor, return the **previous** page of `pageSize` items and a new cursor pointing to the start of that page. If there is no previous page, return an empty list and a "start" cursor. Requirements: - Define what the cursor contains (it could just be an index or a more complex token). - All operations should run in **O(pageSize)** time. - Handle edge cases correctly, including: - Moving past the last page with `getNextPage`. - Moving before the first page with `getPrevPage`. - Cases where `len(items)` is not a multiple of `pageSize`. Implement the data structure and its methods with clear handling of indices and cursors.

Quick Answer: This question evaluates understanding of pagination mechanics, cursor/token design, array indexing, and state management for bidirectional (forward and backward) navigation.

Related Interview Questions

  • Implement an In-Memory Database - Coinbase (hard)
  • Implement a Coin-Constrained Jump Strategy - Coinbase (hard)
  • Implement Game Physics and Block Mining - Coinbase (hard)
  • Compute Total Manual Distance - Coinbase (medium)
  • Implement a Flappy Bird Jump Agent - Coinbase
Coinbase logo
Coinbase
Dec 8, 2025, 6:30 PM
Software Engineer
Technical Screen
Coding & Algorithms
11
0

You are asked to extend a basic pagination system to support forward and backward navigation, similar to a cursor-based API.

You are given:

  • A zero-indexed array of items items sorted in a fixed, deterministic order.
  • An integer pageSize > 0 .

Design a paginator with the following operations:

  1. getFirstPage() → returns the first pageSize items and a cursor representing the position after the last returned item.
  2. getNextPage(cursor) → given a cursor returned by a previous call, return the next pageSize items and a new cursor. If there are no more items, return an empty list and a special "end" cursor.
  3. getPrevPage(cursor) → given a cursor, return the previous page of pageSize items and a new cursor pointing to the start of that page. If there is no previous page, return an empty list and a "start" cursor.

Requirements:

  • Define what the cursor contains (it could just be an index or a more complex token).
  • All operations should run in O(pageSize) time.
  • Handle edge cases correctly, including:
    • Moving past the last page with getNextPage .
    • Moving before the first page with getPrevPage .
    • Cases where len(items) is not a multiple of pageSize .

Implement the data structure and its methods with clear handling of indices and cursors.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Coinbase•More Software Engineer•Coinbase Software Engineer•Coinbase Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.