Back to problems

Paginate forward and backward through results

Algorithm · Coinbase · Medium

You are given an array items that is already sorted in a fixed, deterministic order, along with a positive integer page_size. Implement a cursor-based paginator that can page through items both forward and backward. A cursor is an integer boundary in the range [0, items.length]. For forward pagination, the cursor represents the exclusive end index of the page that was just returned. For backward pagination, the returned cursor represents the start index of the page that was…

Checking your access…