Dsa
Intervals
Easy
Loading Dock Buffer
A logistics center has trucks arriving with [start_time, end_time]. After a truck finishes using a dock, a buffer period of 'B' minutes is required for cleanup before another truck can use the same dock. Find the minimum number of docks required to accommodate all trucks.
Example:
Input: N=3, B=5
Trucks: [10, 20], [15, 25], [22, 30]
Truck 1: Dock 1 (Ends 20, free at 25)
Truck 2: Needs Dock 2 (Ends 25, free at 30)
Truck 3: Needs Dock 3 (Arrives 22, Dock 1 not free until 25)
Output: 3
Key concepts
intervalsgreedymin-heap
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now