Skip to main content
All Questions

Debug a mock Dasher Assignment Service.

Unlock detailed company stats for this questionUpgrade

A single main.py (or equivalent in your language) contains business logic for a mock Dasher Assignment Service used to assign dashers to deliveries. Identify the logic bugs and bad design/coding practices and improve the codebase, prioritizing logic bugs.

Interfaces given:

  • User class: just an ID attribute, instantiated with the ID.
  • Dasher class: a special, very lightweight type of user.
  • RemoteDeliveryRecordingService: a stubbed logging service you may extend, with placeholder signatures recordDasherAdd(dasherId, timestamp) and recordDasherPicking(dasherId, timestamp).
  • DeliveryAssignmentService: the main code; its constructor takes a RemoteDeliveryRecordingService instance.

Implemented (buggy) functions:

  • addDasher(id): takes an id and creates a Dasher object to add to the pool.
  • pickKey(): random int function that chooses a random id from the pool.
  • adjustMap(key): helper that tries to process the pool after a dasher is picked.
  • pickDasher(): calls pickKey(), records the picked dasher through the RemoteDeliveryRecordingService, then calls adjustMap.

Follow-ups: additional test cases, and optimizing the solution beyond the broken implementation provided.

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.