2dbi
Home/Zepto/Minimum Delivery Agents to Fulfill All Orders Within 10-Minute SLA
ZZepto·DSASDE-1DSA Round

Minimum Delivery Agents to Fulfill All Orders Within 10-Minute SLA

Problem

You have n delivery orders, each with an arrivalTime and a required deliveryDeadline. Each agent can handle one order at a time and takes exactly travelTime minutes per delivery. Find the minimum number of agents needed so that all orders are delivered within their deadline.

Example

orders = [{arrival:0, deadline:10}, {arrival:1, deadline:10}, {arrival:0, deadline:10}]
travelTime = 8
Output: 2

Constraints

  • 1 ≤ n ≤ 10^5

Approach

Greedy interval scheduling — sort by deadline, use a min-heap to track when agents become free.

Follow-up

Agents have a maximum shift of 4 hours. How does this affect the solution?

added 6 days ago
LeadersAccount