Reported September 2026
DoorDashdesign

Random Dasher Set Operations

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

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

The mistake that sinks a first attempt on this DoorDash OA, reported September 2026, is the REMOVE operation. Candidates delete from the middle of the array, or forget to fix the map after the swap, and every later PICK returns the wrong dasher. The problem is Random Dasher Set Operations, a hash-table plus dense-array design where ADD, REMOVE and PICK all need O(1) behavior. It's a known shape, so you can walk in with the script. If you blank on the swap-and-pop order during the live assessment, StealthCoder is the quiet safety net that reads the screen and hands you the logic.

The problem

Process a finite ordered array operations against one initially empty set of dasher IDs. Maintain both a dense array of IDs and a map from each ID to its current array index.
Each operation has one of these forms:
ADD id: if id is absent, append it to the array, record its index, and return true. If it is already present, leave the state unchanged and return false.
REMOVE id: if id is absent, leave the state unchanged and return false. Otherwise, move the last array element into the removed element's slot, update that moved element's map entry, delete the old last element, and return true.
PICK draw: if the set is empty, return null. Otherwise, return the ID at index floorMod(draw, size) in the current dense array.
Return one string result per operation, in order. Boolean results are the lowercase strings true and false.
Operational follow-ups
The judged operations are single-threaded and local. Be prepared to explain how serialized mutation or locking protects the array/map invariant, and how bounded timeouts, retries, and circuit breaking would isolate slow dependencies.

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

Examples
Example 1
operations = ["ADD d1","ADD d2","PICK 0","REMOVE d1","PICK 0","REMOVE d1"]
return = ["true","true","d1","true","d2","false"]
After removing d1, d2 moves into index 0. The second pick therefore returns d2.
Example 2
operations = ["ADD a","ADD b","ADD c","REMOVE b","PICK 1","REMOVE c","PICK -1","REMOVE a","PICK 7"]
return = ["true","true","true","true","c","true","a","true","null"]
Removing b changes the dense array to [a, c]. A draw of -1 maps to index 0 when only a remains, and picking after the final removal returns null.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is swap-and-pop. Keep a list of IDs and a map from ID to index. On REMOVE, look up the index, copy the last element into that slot, update the moved element's map entry, pop the last element, then delete the removed ID from the map. The pitfall is order. If the removed ID is also the last element, deleting its map entry before you update the moved one, or updating after the delete, resurrects a stale key. Handle that case cleanly. The second pitfall is PICK with a negative draw. Use floorMod, not the plain remainder operator, since -1 must land on a valid index. Return the string null when the set is empty, and lowercase true and false for booleans. Parse each operation by splitting on the first space. The locking and timeout follow-ups are verbal only. If you freeze mid-OA, StealthCoder is the hedge that shows the swap-and-pop code in real time.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Random Dasher Set 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as insert delete getrandom o1. If you have time before the OA, drill that.

⏵ The honest play

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

DoorDash reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Random Dasher Set Operations FAQ

What's the trick in Random Dasher Set Operations?+

Swap-and-pop. Store IDs in a dense array and keep a map of ID to index. On remove, move the last element into the removed slot, update its map entry, pop the array, and delete the removed key. Every operation stays O(1).

Why does PICK use floorMod instead of a normal modulo?+

Draws can be negative. In most languages, -1 % 3 gives -1, which is an invalid index. floorMod always returns a value from 0 to size-1, so PICK -1 on a one-element set correctly lands on index 0.

What edge case breaks most first attempts?+

Removing the last element. If the removed ID is already at the end, the swap copies it onto itself, and you must still delete its map entry afterward. Update the moved element's index first, then delete the removed key, so nothing stale remains.

Do I need to write locking code for the follow-ups?+

No. The judged operations are single-threaded and local, so the code is plain. The follow-ups are talking points. Say mutations to the array and map are serialized under one lock so they never disagree, and that timeouts, retries and circuit breakers isolate slow dependencies.

How do I prepare for this in 48 hours?+

Write the structure from scratch twice. Code ADD, REMOVE and PICK, then trace Example 2 by hand to confirm the array becomes [a, c] after removing b. Test removing the last element and picking from an empty set. Prepare a two-sentence answer on locking and circuit breaking.

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

OA at DoorDash?
Invisible during screen share
Get it