Reported October 2026
OpenAIsimulation

Durable Work Queue Operations

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

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

The edge case that sinks most people on this OpenAI question, reported in October 2026, is lease expiry. A task whose deadline equals the current timestamp is already gone before the operation runs. Miss that and your output drifts from the expected one. This is a queue simulation: ADD, RESERVE, FAIL, COMPLETE, all driven by nondecreasing timestamps and a lease duration. You're reading the problem 48 hours out, so the pattern matters more than polish. Expire first, then act. If you blank during the live OA, StealthCoder runs invisibly as a safety net and gives you the structure while you type.

The problem

Simulate a durable work queue over a finite ordered sequence of operations. For operation i, use operations[i], taskIds[i], and timestamps[i]. Timestamps are nondecreasing.
Before processing each operation at time t, expire every active reservation whose deadline is at most t. A successful reservation at time t has deadline t + leaseDuration. Each successful reservation consumes one attempt.

Examples
Example 1
operations = ["ADD","ADD","RESERVE","FAIL","RESERVE","COMPLETE","RESERVE"]
taskIds = ["a","b","","a","","b",""]
timestamps = [0,0,1,2,2,3,4]
leaseDuration = 3
maxAttempts = 2
return = ["ADDED","ADDED","a","REQUEUED","b","COMPLETED","a"]
Task a is reserved first, then its failure moves it behind b. The next two reservations therefore return b and then a.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is ordering. Before every operation at time t, expire every active reservation with deadline <= t. Use a map from taskId to its state (attempts used, deadline, status) plus a deque for the ready queue. Keep reservations in a map or a min-heap by deadline so expiry is cheap. The pitfall is the boundary: deadline at most t means expired, not still active. The second pitfall is what happens on expiry and on FAIL. Both should requeue the task at the back, and the example shows FAIL putting a behind b. Each successful reservation consumes one attempt, so check maxAttempts before requeueing. The statement as given doesn't spell out what happens at the limit, so confirm that rule against the full text. Also guard against operations on tasks that aren't actively reserved. StealthCoder is the hedge if you freeze on these rules mid-OA, but trace the example by hand first.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Durable Work Queue Operations 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 by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

OpenAI reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Durable Work Queue Operations FAQ

What's the trick in the OpenAI Durable Work Queue question?+

Process expiry before every operation. Any reservation with deadline <= t is released first, then you handle the current operation. Pair a deque for ready tasks with a map of per-task state. Most wrong answers come from running the operation first or treating the deadline as inclusive.

How hard is this one really?+

It's easy on algorithms and tricky on details. There's no clever data structure, just a careful simulation. The difficulty is tracking state transitions correctly: added, reserved, requeued, completed, expired. Trace the example by hand and you'll catch most mistakes.

Does the deadline boundary really matter?+

Yes. A reservation made at time t gets deadline t + leaseDuration. If the next operation lands exactly on that time, the reservation is already expired. Using < instead of <= gives wrong output on exactly the tests built to catch it.

What data structures should I use?+

A deque or list for the ready queue, a hash map from taskId to attempts, status and deadline, and optionally a min-heap keyed by deadline for fast expiry. With small inputs a linear scan of active reservations works too, but the heap is cleaner.

How do I prepare in 48 hours?+

Write the simulation loop from scratch twice. Practice similar queue and lease problems with timestamps. Then list every state transition and the order of checks. Get the expiry-first rule into muscle memory, since that's the edge case that breaks naive solutions.

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

OA at OpenAI?
Invisible during screen share
Get it