Earliest Delivery Promise Across Scheduled Linehaul Trucks
Last updated: November 29, 2026
Quick Overview
A package becomes ready at a fulfillment center at a given minute; trucks between fulfillment centers, sort centers and delivery camps leave only at scheduled departure times and take a fixed duration, and each node needs some handling minutes before a package can leave. Compute the earliest minute the package can reach a target camp.
Coupang
November 29, 20260
0
0 solved
A package becomes ready at a fulfillment center at a given minute; trucks between fulfillment centers, sort centers and delivery camps leave only at scheduled departure times and take a fixed duration, and each node needs some handling minutes before a package can leave. Compute the earliest minute the package can reach a target camp.
The date Coupang shows under 'Rocket Delivery: arriving tomorrow' depends on whether an order can make the right trucks through the middle mile. This onsite problem checks whether you see that time-dependent edges still allow Dijkstra when waiting is allowed, and whether you handle schedules efficiently.
What the Interviewer Expects
- Model nodes as facilities and edges as legs with sorted departure lists
- Recognise the FIFO property: arriving earlier never makes you leave later, so Dijkstra on arrival time is correct
- Binary search the next departure after arrival plus handling
- Skip stale heap entries and stop early when the target pops
- Return None when every remaining truck is missed
- State complexity in terms of legs and departures
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 produce the full route and which truck to load, not just the time?
- How do you extend to a next-day schedule that repeats every 1,440 minutes?
- Trucks have capacity; how does the problem change when a truck can be full?
- How would you precompute this for millions of product page views 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: legs[u] = [(v, departures, duration)] with departures sorted in minutes, handling[node] minutes, a source, a target camp and a ready time. Output: earliest arrival minute at the target, or ...
High-Level Design
Treat it as a shortest path where the cost of an edge depends on when you reach it. From node u at time t, the package can leave at the first departure >= t + handling[u] and arrives at `dep + d...