Back to problems

Debug a Random Dasher Registry

Algorithm · DoorDash · Hard

A registry stores active dasher IDs and supports adding an ID, checking whether an ID is already present, and removing one ID uniformly at random. The intended representation uses a dense array ids in which every active ID appears exactly once, paired with a hash map idToIndex that maps each ID to its current array position. With this representation, local operations can be performed in expected $$O(1)$$ time. The supplied implementation is not faithful to that…

Checking your access…