One UTF-8 JSON value matching the structures shown in the examples.
Practice Mode • Backend & APIs • medium
Order Cursor Page
Page seller orders without offset drift.
Problem
You are implementing page seller orders without offset drift. The input is one JSON value. Return exactly the JSON or scalar result described by the examples, with stable ordering and no extra logging. Return a deterministic cursor page over a stable compound ordering. Explain your reasoning and complexity during interview review; the judge evaluates only the returned result.
One deterministic JSON value or scalar with no explanatory text.
O(n log n) time, O(page) output space
function-stdin-json-v1
Examples
Input: {"limit":2,"rows":[{"createdAt":1,"id":"id1"},{"createdAt":2,"id":"id2"},{"createdAt":3,"id":"id3"},{"createdAt":4,"id":"id4"},{"createdAt":5,"id":"id5"},{"createdAt":6,"id":"id6"},{"createdAt":7,"id":"id7"},{"createdAt":8,"id":"id8"}]}
Output: {"items":[{"createdAt":1,"id":"id1"},{"createdAt":2,"id":"id2"}],"nextCursor":"2|id2"}This example demonstrates the core backend apis invariant.
Input: {"limit":3,"rows":[]}
Output: {"items":[],"nextCursor":null}This example covers the empty or minimum boundary.
Constraints
- Input is valid UTF-8 JSON and is at most 64 KB.
- Output must be deterministic for identical input.
- Do not use network access, persistent filesystem writes, subprocesses, or environment secrets.
- Handle the empty or minimum boundary shown in the examples.
Progressive hints
Sign in to reveal hints one at a time.
Integrity: hidden tests, editorial solutions, and assessment-only cases are never sent to the browser as answer keys. Final execution occurs only in the separately isolated runner.
Execution unavailable until runner deployment and certificationdisabled • pending
Sign in to code
You can review the complete problem publicly. Sign in to save encrypted drafts and submit to the isolated runner.
Sign in