Dasher Shift Utilization from Overlapping Stacked Delivery Intervals
Last updated: November 29, 2026
Quick Overview
Given each Dasher's dash shifts and the pickup-to-dropoff intervals of their deliveries (which overlap when orders are stacked), use pandas to compute busy minutes as the union of delivery intervals clipped to the shift, and utilization as busy minutes over online minutes.
DoorDash
November 29, 20260
0
0 solved
Given each Dasher's dash shifts and the pickup-to-dropoff intervals of their deliveries (which overlap when orders are stacked), use pandas to compute busy minutes as the union of delivery intervals clipped to the shift, and utilization as busy minutes over online minutes.
DoorDash batches multiple orders onto one Dasher, so simply summing delivery durations double counts time and can push utilization above 100%. Logistics DS onsites use this to test interval merging in pandas, clipping to a window, and keeping shifts with no deliveries in the denominator.
What the Interviewer Expects
- Recognize that stacked deliveries overlap and summing durations overcounts
- Clip each delivery interval to its shift before merging
- Merge overlapping intervals with a running max of end times, vectorized per group
- Keep zero-delivery shifts with zero busy time via a left merge
- Validate that utilization lies between 0 and 1
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you split busy time into 'carrying one order' versus 'carrying two or more'?
- How would you compute this in SQL?
- Should time driving to the store before pickup count as busy? How would the definition change the metric?
- How would you aggregate utilization to a market level: average of ratios or ratio of sums?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
shifts(dasher_id, shift_id, shift_start, shift_end) and deliveries(dasher_id, shift_id, start_ts, end_ts) where start is pickup and end is dropoff. A delivery can begin slightly before the logged ...
Approach
Sort deliveries by shift and start time. For each row compute the maximum end time among all earlier rows in the shift (cummax().shift()). If the current start is after that running max, it starts...