Longest Streak of Consecutive Late Deliveries per Dasher

Last updated: November 29, 2026

Quick Overview

Given a deliveries table with promised and actual drop-off times, find each Dasher's longest run of back-to-back late deliveries in the last 30 days and return Dashers whose longest streak is at least 3.

DoorDash
Data Manipulation (SQL/Python)
Data Scientist
DoorDash
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


Given a deliveries table with promised and actual drop-off times, find each Dasher's longest run of back-to-back late deliveries in the last 30 days and return Dashers whose longest streak is at least 3.

DoorDash's Dasher quality and support teams care about patterns, not single late orders: a run of consecutive lates often signals a vehicle problem, a bad zone, or a Dasher who needs outreach. This shows up in the DS technical screen as a gaps-and-islands window function problem, and the interviewer checks whether you can turn row order into groups without a procedural loop.

What the Interviewer Expects
  • Define lateness explicitly (for example more than 5 minutes past the promised time) and filter to completed deliveries
  • Use the difference of two ROW_NUMBER sequences to label consecutive runs
  • Break ties in ordering deterministically with delivery_id
  • Return one row per Dasher with streak length and its start and end time
  • Explain why a self-join or LAG-only approach is harder to get right
Key Topics to Cover
gaps and islands
ROW_NUMBER
window functions
streak detection
tie-breaking
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you instead count streaks that reset only on an on-time delivery, ignoring cancelled orders in between?
  • How would you compute the longest streak per Dasher per week in one query?
  • What changes if a Dasher completes two stacked deliveries with the same delivered_at timestamp?
  • How would you use this output to trigger a support outreach without punishing Dashers in bad weather markets?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Assume deliveries(delivery_id, dasher_id, status, promised_at, delivered_at). A delivery is late if delivered_at > promised_at + 5 minutes (I would confirm the grace window with the interviewer). ...

Approach

Classic gaps and islands. Number every delivery per Dasher by time (rn_all), and separately number deliveries per Dasher within the same late flag. Inside a run of identical flags both counters in...


Submit Your Answer
Markdown supported