You are given a list of event time points (integers), e.g. [1, 3, 5, ...].
You need to group all events into batches under these constraints:
B
events (capacity).
t0
be the
earliest time
in a batch. Then
every
event time
t
in that batch must satisfy:
t - t0 <= W
(i.e., all events lie within a window of size
W
starting at the earliest event in the batch).
Goal: return the minimum number of batches needed to include all events.
Input:
times
: array of integers (not guaranteed sorted)
B
(capacity),
W
(window)
Output:
Notes:
B >= 1
,
W >= 0
.
In a delivery setting, each order occupies a rider for an interval of time [start, end) (or [start, end]—clarify your convention).
Given a list of order time intervals, compute the minimum number of riders needed so that no rider is assigned overlapping orders.
Input: list of intervals (start, end)
Output: minimum number of riders required
(Expect a sweep-line / min-heap style solution.)