This question evaluates a candidate's competency in implementing efficient paginated data retrieval and API design, covering offset- and cursor-based pagination, stable ordering when timestamps collide, consistency concerns when new records arrive, and analysis of time and space complexity.
Given a large list of transaction records (id, userId, amount, createdAt), implement APIs to return transactions in reverse chronological order with pagination. Support both offset-based and cursor-based (createdAt,id) pagination; return page data plus metadata (hasNext, nextCursor, total if offset mode). Ensure stable ordering when multiple transactions share the same timestamp, and discuss how to keep results consistent when new records arrive between requests. Provide time/space complexities and key edge cases.