Reported September 2026
Crestadesign

Dynamic Least-Loaded Job Dispatcher

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

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

Cresta's September 2026 OA hands you a job dispatcher that looks like a simulation but hinges on one data structure choice: how you find the least-loaded executor without scanning everything on every DISPATCH. With up to 100000 operations, a naive loop will hurt. The spec has a round-robin cursor, per-executor FIFO queues, and a REMOVE that redistributes jobs using the same rule. It's a design problem in disguise. If you blank on the structure mid-assessment, StealthCoder runs invisibly on your desktop as a safety net.

The problem

Process operations on a job dispatcher. Executors retain insertion order, each executor owns a FIFO queue, and the dispatcher maintains a round-robin cursor into the current executor order.
["ADD", executor] adds an empty executor and returns OK.
["DISPATCH", job] chooses an executor with the smallest queue. If several are tied, scan cyclically from the cursor and choose the first tied executor. Advance the cursor to the executor after the chosen one, enqueue the job, and return the chosen executor ID.
["EXECUTE", executor] removes and returns that executor's oldest job, or the empty string when its queue is empty.
["REMOVE", executor] removes the executor, then redistributes its queued jobs in FIFO order using the same dispatch rule. Return OK.
["STATE"] returns all executors in insertion order as executor:job1,job2 groups joined by |. An empty queue has nothing after the colon.
Return one result for every operation.

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

Examples
Example 1
operations = [["ADD","a"],["ADD","b"],["DISPATCH","j1"],["DISPATCH","j2"],["DISPATCH","j3"],["STATE"],["EXECUTE","a"],["DISPATCH","j4"],["STATE"]]
return = ["OK","OK","a","b","a","a:j1,j3|b:j2","j1","b","a:j3|b:j2,j4"]
Least-load choices dominate; the cursor resolves the two equal-load ties.
Example 2
operations = [["ADD","a"],["ADD","b"],["ADD","c"],["DISPATCH","j1"],["DISPATCH","j2"],["DISPATCH","j3"],["DISPATCH","j4"],["REMOVE","a"],["STATE"]]
return = ["OK","OK","OK","a","b","c","a","OK","b:j2,j1|c:j3,j4"]
The removed executor's jobs are redistributed in their original FIFO order.
Example 3
operations = [["ADD","solo"],["EXECUTE","solo"],["STATE"]]
return = ["OK","","solo:"]
Executing an empty queue returns the empty string.

Constraints
1 <= operations.length <= 100000.
Executor and job IDs contain 1 to 30 alphanumeric characters and contain neither comma, colon, nor vertical bar.
An executor is added at most once while present, and every referenced executor exists.
DISPATCH occurs only when at least one executor exists.
REMOVE occurs only when at least one other executor remains.
Each job ID is dispatched at most once.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is ordering. Executors keep insertion order, so the cursor is really a position in that order, and ties are resolved by scanning cyclically from it. Keep a deque per executor and an ordered list of executors. The simple approach scans all executors for the minimum size, then picks the first tied one at or after the cursor. That's O(n) per dispatch, which may be fine or may time out depending on how many executors exist. A faster route groups executors by load and uses sorted structures to find the first tied index at or after the cursor. The pitfall is the cursor after REMOVE. When an executor disappears, the indices shift, so adjust the cursor if the removed one sat before it. Also, redistribute jobs in FIFO order after removal, and remove the executor first. Example 2 checks exactly this. If the cursor logic tangles during the live OA, StealthCoder is the hedge that reads the spec and gives you a working structure.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Dynamic Least-Loaded Job Dispatcher 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. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Cresta reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Dynamic Least-Loaded Job Dispatcher FAQ

What's the trick in the Cresta dispatcher problem?+

Separate the two concerns. Find the minimum queue size, then break ties by scanning cyclically from the cursor in insertion order. Each executor holds a FIFO queue. Most bugs come from the cursor, not the queues, so get that right first.

How hard is this one really?+

The logic is medium. The difficulty is the number of small rules: cursor advance, tie scan, REMOVE redistribution, STATE formatting. None is hard alone. Miss one and an example breaks. Trace Example 2 by hand before you submit.

How should I handle the cursor when an executor is removed?+

Store the cursor as an index into the current executor list. When you remove an executor at an index lower than the cursor, decrement the cursor. Wrap with modulo when it passes the end. Then redistribute the removed jobs using the normal dispatch rule, which advances the cursor each time.

Will a simple O(n) scan per dispatch pass?+

It might, but 100000 operations with many executors can get slow. The safe path is to write the simple version first so it's correct, then optimize with load grouping if you have time. Correctness on the examples matters more than cleverness.

How do I prepare for this in 48 hours?+

Practice stateful simulation problems where you process a list of commands and return one result each. Write a small class with a method per command. Test the empty-queue EXECUTE and the STATE format with an empty queue, because those edge cases are easy to miss.

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

OA at Cresta?
Invisible during screen share
Get it