Split a Delivery Route Among K Dashers to Minimize the Longest Shift

Last updated: November 29, 2026

Quick Overview

Given the drive time of each consecutive leg of a long multi-stop route, split the legs into at most k contiguous pieces, one per Dasher, so that the longest piece is as short as possible, and return that minimum.

DoorDash
Coding & Algorithms
Software Engineer
DoorDash
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given the drive time of each consecutive leg of a long multi-stop route, split the legs into at most k contiguous pieces, one per Dasher, so that the longest piece is as short as possible, and return that minimum.

Large batched routes (a catering run or a DashMart restock with many stops) sometimes need splitting across several Dashers. The interviewer wants you to spot binary search on the answer with a greedy feasibility check, prove monotonicity, and compare it with the O(k n^2) DP.

What the Interviewer Expects
  • Identify the search bounds: max leg and total time
  • Write a greedy check that counts pieces needed for a cap
  • Argue the check is monotone in the cap
  • Binary search for the smallest feasible cap
  • Mention the DP alternative and its cost
Key Topics to Cover
binary search on answer
greedy feasibility
partitioning
monotonicity
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you return the actual split points?
  • What if each Dasher also has a different maximum shift length?
  • What if the legs are not required to stay contiguous?
Sharpen Your Skills on Codemia

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

Practice DSA Problems
Sample Answer
Requirements
  • Input: stops (positive leg times) and k >= 1.
  • Pieces must be contiguous and cover every leg.
  • Output: the minimum possible value of the largest piece sum....
High-Level Design

If a cap C is feasible (we can split into at most k pieces each with sum at most C), then any larger cap is also feasible, so feasibility is monotone and we can binary search C. The check is greedy: f...


Submit Your Answer
Markdown supported