This question evaluates a candidate's ability to process time-based event streams, manage overlapping active intervals, and compute aggregate payouts under concurrency constraints.
You are given a list of events describing when a delivery driver ("Dasher") accepts and fulfills different orders.
events: a list of records (time, orderId, action) where:
time
is an integer timestamp in
minutes
(e.g., minutes since midnight).
orderId
is a string identifier.
action
is one of:
ACCEPT
,
FULFILL
.
Return the total pay as a double, rounded to two decimals.
events
may be unsorted; you must process them in increasing
time
.
time
, process all
ACCEPT
actions
before
FULFILL
actions at that same time.
[t_i, t_{i+1})
, the number of active orders is considered constant and equals the active set
after applying
all actions at
t_i
.
Events:
Pay:
Total = 14.4