Practice problem · Coinbase · Medium

Transaction History: Cursor Pagination

A transaction history endpoint returns a customer's transactions in pages, sorted by time, with an opaque cursor for the next page. 4 stages in Python with an AI assistant. Pro.

Stage 1 of 4: Fix the time-sorted pagination

Background. A transaction history endpoint returns a customer's transactions in pages, sorted by time, with an opaque cursor for the next page. API.md is the contract; service.py lists, cursor.py encodes and decodes cursors, store.py holds the ledger in memory.

Three tickets are open against it: customers scrolling their history see rows go missing; a buggy web build sends mangled cursors and the endpoint crashes instead of answering InvalidCursor; and old mobile builds still send the previous cursor format, which has to keep working.

The tests in tests/test_part1_cursor.py fail.

Find the defects and fix them. Keep the signature of list_transactions and the sample ledger's order as API.md states them.

Done when Submit goes green.

Constraints

  • Python 3.12+ standard library only
  • Time limit: 10 seconds per test
  • Editable: service.py, cursor.py, store.py
  • Read-only: API.md, models.py, test_helpers.py, data/api.log, docs/PR-142.md, all tests/test_*.py files

What comes after stage 1

The next stages open once the tests for the one before them pass. Each raises the bar, the way an interviewer does in the room.

  1. Stage 2: Sort by amount, safe cursors.
  2. Stage 3: Diagnose the timeouts.
  3. Stage 4: Review PR-142: backward pagination.

The files you get

  • Yours to edit: service.py, cursor.py, store.py.
  • Read-only: API.md, models.py, test_helpers.py, data/api.log, docs/PR-142.md, tests/__init__.py.
  • Tests you can read and run: tests/test_part1_cursor.py. Hidden tests run on Submit.

The round: an agent in the editor

The assistant here works like the one in the interview IDE. It reads your files, runs code and proposes changes, and you accept or reject each one. It doesn't volunteer ideas, so what gets built is what you asked for. Along the way the interviewer asks about your decisions, and at the end the report says what you checked and what you accepted unread.

Frequently asked, briefly answered

Is Transaction History: Cursor Pagination free?

It is a Pro problem. Free plan includes one complete problem, plus the first stage of several more, so you can see how a round works before you pay.

Which company asks something like this?

Coinbase. It is modelled on Coinbase's round: Onsite "AI Enhanced Pilot" round: an in-IDE assistant and an existing service, four sub-tasks in 60 minutes (find a bug, design a feature, diagnose a production timeout, review a PR), screen-shared so the interviewer sees how you prompt and validate.

Do I bring my own AI tool?

No. The assistant is in the editor, same as in the interview IDEs at Meta, Stripe and Amazon. What you choose at Begin is the format: an agent that proposes changes you accept or reject, an answer-only assistant that can't write code, or no assistant at all.

What does the interviewer ask?

4 questions along the way about your own code, and one at the end about the whole session. A weak answer gets one follow up. The answers go into the report, which ends with a hire or no hire verdict.

Start the problem

Sign in and the problem opens where you left it. New here? An account takes a minute to create, and the Pro plan starts at the first stage of this problem.

Start this problem → Sign in

More like it: every practice problem, how Coinbase runs its AI round, the AI coding interview guide.