Topfolio
Career TracksFree CoursesPracticeWork ExperienceProjects
For Employers
Start Free
Topfolio

Learn data analytics online. Real skills, real projects, real community.

courses

  • Career Tracks
  • Work Experience
  • Best Data Analyst Course in India
  • SQL Fundamentals
  • SQL Advanced
  • Python for Data
  • Micro Free Courses

practice

  • SQL Fundamentals Interview Test
  • SQL Advanced Coding Test
  • All Practice Tests

resources

  • How to Become a Data Analyst
  • SQL Interview Questions
  • Data Analyst Salary Guide
  • Free Datasets for Practice
  • SQL vs NoSQL Guide
  • Data Analyst vs Data Engineer vs Data Scientist

employers

  • Enterprise Screening
  • AI Proctoring Demo
  • Volume Pricing
  • Employer Portal

company

  • About
  • Terms
© 2026 Topfolio. All rights reserved.Made with ❤️ for aspiring analysts
Topfolio
Career TracksFree CoursesPracticeWork ExperienceProjects
For Employers
Start Free

Paginate with an Opaque Cursor

medium~15 min20 pts
📊 View Insights

Problem

# Paginate with an Opaque Cursor Offset pagination (`?page=7`) skips or duplicates rows when data changes between requests. Cursor pagination (`?cursor=`) stays stable. ### Task Implement `paginate(ids: list[int], cursor: int | None, limit: int) -> tuple[list[int], int | None]` returning `(page, next_cursor)` where `page` holds up to `limit` ids strictly greater than `cursor` (or from the start when `cursor` is `None`), and `next_cursor` is the last id of the page when more rows remain, else `None`. ### Example `paginate([1, 2, 3, 4, 5], None, 2)` → `([1, 2], 2)`; `paginate([1, 2, 3, 4, 5], 2, 2)` → `([3, 4], 4)`; `paginate([1, 2, 3, 4, 5], 4, 2)` → `([5], None)`.
fastapipaginationapi-design
📊
📊 View Question Telemetry & Insights
Failure rate, silent bug autopsy & optimal query construction
Inspect →

Master SQL & Data Analytics

Ready to take your skills to the next level? Enroll in our comprehensive Data Analyst Career Track to master SQL, Python, Excel, and Power BI.

Explore the 12-Week Data Analyst Career Track

Related questions

  • Implement FastAPI Lifespan Model Cachingmedium
  • Verify a Webhook HMAC Signaturemedium
  • Generate Collision-Safe Short Codeseasy
  • Enforce Model Schema Signatures with MLflowmedium
  • Compute Population Stability Index (PSI) with Epsilon Smoothingmedium
  • Deterministic Salted Hash Routing for A/B Canarieseasy
  • Two-Sample Kolmogorov-Smirnov Drift Test Runnereasy
  • Longest Substring with At Most K Distinct Charactersmedium
SQL Editor

Run your code to see the result here.

Topfolio

Learn data analytics online. Real skills, real projects, real community.

courses

  • Career Tracks
  • Work Experience
  • Best Data Analyst Course in India
  • SQL Fundamentals
  • SQL Advanced
  • Python for Data
  • Micro Free Courses

practice

  • SQL Fundamentals Interview Test
  • SQL Advanced Coding Test
  • All Practice Tests

resources

  • How to Become a Data Analyst
  • SQL Interview Questions
  • Data Analyst Salary Guide
  • Free Datasets for Practice
  • SQL vs NoSQL Guide
  • Data Analyst vs Data Engineer vs Data Scientist

employers

  • Enterprise Screening
  • AI Proctoring Demo
  • Volume Pricing
  • Employer Portal

company

  • About
  • Terms
© 2026 Topfolio. All rights reserved.Made with ❤️ for aspiring analysts