Reported September 2026
Lyftsimulation

Stateful Paginated Fetch N

Reported by candidates from Lyft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Lyft OA. Under 2s to a working solution.
Founder's read

Lyft's Stateful Paginated Fetch N, reported in September 2026, comes down to one structure: a hash map from page token to page, plus a buffer that survives between calls. That's the whole trick. The problem reads like a systems question, but it's a simulation with a queue and a pointer. If you're taking this OA in the next couple of days, learn the buffer rule cold. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the logic here is small enough to own before you start.

The problem

Simulate repeated calls to a stateful fetch_n reader over an immutable token-paginated source.
The source is described by parallel arrays:
pageTokens[i] identifies one page.
pageItems[i] is that page's ordered item list.
nextTokens[i] is the next page token, or the empty string when the source ends.
startToken is the first token, or the empty string for an already exhausted source. Tokens are unique, every non-empty next token names a supplied page, and following tokens from startToken reaches the empty string without revisiting a page. A page may contain no items.
Process every positive value requests[j] as one call on the same reader. That call returns up to requests[j] remaining items in source order. Buffer fetched items that the call does not return, skip empty pages, and continue from the preserved buffer and token on the next call. Calls after exhaustion return an empty array.
Return one item array per request, in request order.
Reliability follow-up
Judged page fetches succeed exactly once. Be prepared to explain bounded retries, idempotent token fetches, timeout handling, and why a failed fetch must not advance committed reader state.

Function
fetchBatches(startToken: String, pageTokens: String[], pageItems: String[][], nextTokens: String[], requests: int[]) → String[][]

Examples
Example 1
startToken = "p1"
pageTokens = ["p1","p2","p3"]
pageItems = [["A","B","C"],["D"],["E","F"]]
nextTokens = ["p2","p3",""]
requests = [2,3,4]
return = [["A","B"],["C","D","E"],["F"]]
The first call buffers C. The second call consumes that buffer and continues through pages p2 and p3. Only F remains for the final call.
Example 2
startToken = "a"
pageTokens = ["a","b","c"]
pageItems = [[],["x","y"],[]]
nextTokens = ["b","c",""]
requests = [1,2,1]
return = [["x"],["y"],[]]
The reader skips the empty first page, buffers y after returning x, and eventually skips the empty terminal page before reporting exhaustion.

Constraints
pageTokens.length, pageItems.length, and nextTokens.length are equal.
Page tokens are unique, and every non-empty next token names a supplied page.
The chain from startToken is acyclic and ends at the empty token.
Every value in requests is positive.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Build a map from token to index so you can jump from a token to its items and next token in O(1). Keep three pieces of reader state: the current token, a buffer of leftover items, and an exhausted flag. For each request, drain the buffer first. While you still need items and the token isn't empty, fetch the page, append its items, and advance the token. Then slice off exactly requests[j] items and keep the rest buffered. The common pitfall is dropping the leftover items when a page overshoots the request, or looping forever on empty pages. Empty pages just advance the token. Use an index pointer into the buffer instead of popping from the front of an array. The reliability follow-up is verbal: retry with a bound, make fetches idempotent by token, and only commit the token and buffer after a fetch succeeds. If you freeze on the buffer logic live, StealthCoder is the hedge.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Stateful Paginated Fetch N cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Lyft's OA.

Lyft reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Stateful Paginated Fetch N FAQ

What's the trick in Lyft's Stateful Paginated Fetch N?+

Persist state across calls. You need a token-to-page map, a buffer of leftover items, and the current token. Each request drains the buffer first, then fetches pages until it has enough or the token is empty. Overshoot from a page stays in the buffer for the next call.

How hard is this problem really?+

Easy to medium. There's no clever algorithm, just careful state handling. Most failures come from losing leftover items, mishandling empty pages, or returning nothing correctly after exhaustion. If you trace Example 1 by hand once, you'll catch most of those bugs.

How do I handle empty pages?+

Treat them like any other page. Fetch, append zero items, advance to the next token, and keep looping while you still need items and the token isn't empty. Example 2 tests exactly this, including an empty terminal page before exhaustion is reported.

What should I say about the reliability follow-up?+

Say retries are bounded, with a timeout per fetch. Fetching by token is idempotent, so retrying is safe. A failed fetch must not change committed state, so you stage the new items and token and only commit them after success. Keep it short and concrete.

How do I prepare for this in 48 hours?+

Write the solution once from scratch, then trace both examples by hand. Practice the buffer-slice step and the exhausted case. Also rehearse a 30-second answer for the retry and idempotency follow-up. That covers the code and the discussion.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Lyft.

OA at Lyft?
Invisible during screen share
Get it