Reported September 2026
Nuroheap priority queue

Thread-Safe Task Storage and Worker Dispatch

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

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

The mistake that sinks a first attempt on this Nuro OA, reported in September 2026, is treating a failed task like a brand new one and shoving it to the back of the line. It goes back to its original ADD position. That's the whole problem. You're simulating a task store with a queue-like structure, three states, and workers that hold one task each. The "thread-safe" wording is bait, since the history is already one legal sequential order. If you blank on the ordering rule mid-assessment, StealthCoder runs invisibly as a safety net and hands you the structure.

The problem

Process a legal linearized history for a thread-safe task store. A task has one of three states: QUEUED, RUNNING, or COMPLETED. Each task keeps its original ADD order, and each worker holds at most one running task.
["ADD", task] creates a unique queued task and produces task:QUEUED.
["DISPATCH", worker] assigns the oldest-added task that is currently queued, producing task:RUNNING. It produces NONE when no task is queued.
["COMPLETE", worker, task] marks that worker's running task completed, frees the worker, and produces task:COMPLETED. Repeating a completion for an already completed task is an idempotent no-op with the same output.
["FAIL", worker, task] frees the worker, returns its task to QUEUED at the task's original ADD position, and produces task:QUEUED.
["RELEASE", worker] behaves like FAIL for that worker's running task. For an idle worker it produces NONE.
Return one string per operation. The supplied sequence is one legal atomic order of concurrent calls; every operation observes the complete state left by its predecessor.

Function
taskWorkerHistory(operations: String[][]) → String[]

Examples
Example 1
operations = [["ADD","t1"],["ADD","t2"],["DISPATCH","w1"],["FAIL","w1","t1"],["DISPATCH","w2"],["COMPLETE","w2","t1"],["DISPATCH","w1"],["RELEASE","w1"]]
return = ["t1:QUEUED","t2:QUEUED","t1:RUNNING","t1:QUEUED","t1:RUNNING","t1:COMPLETED","t2:RUNNING","t2:QUEUED"]
After failure, t1 keeps its earlier ADD position and is dispatched before t2.
Example 2
operations = [["DISPATCH","w0"],["RELEASE","w0"],["ADD","job"],["DISPATCH","w0"],["COMPLETE","w0","job"],["COMPLETE","w0","job"],["DISPATCH","w1"]]
return = ["NONE","NONE","job:QUEUED","job:RUNNING","job:COMPLETED","job:COMPLETED","NONE"]
Empty dispatch and idle release return NONE. Completing the same finished task again is idempotent.

Constraints
1 <= operations.length <= 100000.
Each task and worker ID has length from 1 through 32 and uses ASCII letters, digits, underscores, or hyphens.
Every ADD task ID is unique.
DISPATCH is called only for an idle worker.
FAIL names the exact task currently held by that worker.
COMPLETE names the exact task currently held by that worker or a task already completed by an earlier matching call.
The history is one complete linearization; no operation is partially visible.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is a min-heap keyed by ADD index. Give each task an incrementing sequence number on ADD. DISPATCH pops the smallest index from the heap, so a requeued task naturally jumps ahead of later adds. Keep a map from worker to its running task, and a map from task to state and index. FAIL and RELEASE on a busy worker push the task back with its original index and free the worker. RELEASE on an idle worker returns NONE. COMPLETE on an already completed task just repeats task:COMPLETED without touching anything. The pitfall is a plain FIFO queue, which breaks Example 1 because t1 would land behind t2. Another is forgetting to clear the worker mapping on complete or fail. Each operation costs O(log n), fine for 100000 operations. If the heap ordering slips under pressure, StealthCoder is the hedge during the live OA.

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 Thread-Safe Task Storage and Worker Dispatch 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 Nuro's OA.

Nuro 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.

Thread-Safe Task Storage and Worker Dispatch FAQ

What's the trick in the Nuro task storage problem?+

Use a min-heap keyed by the original ADD sequence number. Dispatch pops the smallest key. When a task fails or is released, push it back with its same key, so it lands ahead of later tasks automatically. A plain queue gets this wrong.

How hard is this problem really?+

Easy to medium. No fancy algorithm, just careful state handling. Most failures come from missing edge cases like idle RELEASE returning NONE, empty DISPATCH returning NONE, and repeated COMPLETE being a no-op. Read the examples closely and you're fine.

Do I need to worry about real threading or locks?+

No. The statement says the input is one legal atomic order of concurrent calls, and each operation sees the full state from the previous one. Write a single-threaded simulation. Adding locks wastes time and adds nothing.

What data structures should I set up?+

A heap of (addIndex, task) for queued tasks, a map worker to running task, and a map task to its state and add index. A counter assigns indexes on ADD. That's all you need for O(log n) per operation.

How do I prepare for this in 48 hours?+

Write this simulation once from scratch using a heap, then test both examples by hand. Also rehearse similar scheduler or queue-with-priority problems. Focus on state transitions and edge cases, not on memorizing algorithms, since the logic here is mostly bookkeeping.

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

OA at Nuro?
Invisible during screen share
Get it