Maximize Orders Delivered Before Their Promised Deadlines
Last updated: November 29, 2026
Quick Overview
A single Dasher handles orders one at a time starting at time zero; each order has a duration and a promised deadline. Choose which orders to deliver, and in what order, to maximize the number delivered on time.
DoorDash
November 29, 20260
0
0 solved
A single Dasher handles orders one at a time starting at time zero; each order has a duration and a promised deadline. Choose which orders to deliver, and in what order, to maximize the number delivered on time.
DoorDash quotes a delivery window to every customer, and lateness drives refunds and churn. This greedy question with a heap exchange argument is a strong signal of algorithmic maturity, and interviewers expect you to justify why dropping the longest job is safe.
What the Interviewer Expects
- Argue that any feasible set can be delivered in deadline order
- Process orders by deadline and keep the chosen durations in a max-heap
- On a deadline miss, drop the longest chosen order
- Give the exchange argument for correctness
- State O(n log n)
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 would you maximize total tip instead of count?
- What if there are two Dashers?
- What if orders have release times (cannot start before the food is ready)?
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
(duration, deadline). - One order at a time, no idle time needed, start at 0.
- An order counts if it finishes at or before its deadline.
- Output: `(count, chosen indices in delive...
High-Level Design
If a set of orders can all be on time, it can be on time when sorted by deadline (earliest deadline first is optimal for feasibility). So scan by deadline, adding each order and its duration to a runn...