Question
Implement keyset (cursor) pagination over a table ordered by (created_ts ASC, id ASC). Rows are given as [id, created_ts] (both integers, the pair is unique). Given a cursor (cursor_ts, cursor_id) and a page size `limit`, return up to `limit` rows that come strictly AFTER the cursor in the ordering — i.e. created_ts > cursor_ts, or (created_ts == cursor_ts and id > cursor_id). Return them in sorted order. A cursor of (-1, -1) means start from the beginning. Up to 50000 rows.
keyset_page(rows: list[list], cursor_ts: int, cursor_id: int, limit: int) → list[list][[[1,100],[2,100],[3,200]],100,1,2]out[[2,100],[3,200]]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.