First Dasher to Reach K Completed Deliveries in an Event Stream
Last updated: November 29, 2026
Quick Overview
Given a time-ordered stream of (dasher_id, status) delivery events, return the first dasher whose count of DELIVERED events reaches k, along with the index of the event that pushed them over.
DoorDash
November 29, 20260
0
0 solved
Given a time-ordered stream of (dasher_id, status) delivery events, return the first dasher whose count of DELIVERED events reaches k, along with the index of the event that pushed them over.
A warm-up in the style of DoorDash phone screens, framed around Dasher challenge rewards (for example, a bonus for the first Dasher in a zone to finish 10 deliveries tonight). The interviewer checks that you pick a hash map quickly, read the status filter carefully, and stop at the first qualifying event instead of counting everything.
What the Interviewer Expects
- Ask which statuses count as a completion
- Use a dictionary of counts keyed by dasher_id
- Return as soon as a count hits k rather than after the full pass
- Handle the no-winner case with a clear sentinel
- State O(n) time and O(d) space
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How does this change if events can arrive out of order by up to 30 seconds?
- What if a delivery can be reversed later (DELIVERED then REFUNDED)?
- How would you run this per zone across millions of events per minute?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: list of
(dasher_id, status)in time order and an integerk >= 1. - Only
DELIVEREDevents count. Cancellations and pickups are ignored. - Output:
(dasher_id, event_index)for the first...
High-Level Design
Keep a dictionary from dasher to completed count. Walk the stream once; on each DELIVERED event increment the count and check whether it just became k. Because counts only increase by one, checkin...