Dasher Pay with Store Waits and Peak Hours
Learn this problemProblem statement
A Dasher earns $0.30 per minute for each active delivery. A delivery becomes active when it is accepted and stops being active when it is fulfilled. Therefore, ordinary concurrent-delivery time is paid at activeDeliveries * $0.30 per minute.
Each string in events has the form HH:MM EVENT orderId, where EVENT is ACCEPT, ARRIVE, PICKUP, or FULFILL. Events are in strictly increasing time order and describe valid order lifecycles.
An ARRIVE event begins a store-wait interval for that order, and its matching PICKUP ends the interval. While the Dasher is waiting at a store, only the order being waited on contributes pay; other active orders do not contribute during that interval. Outside a store wait, every active order contributes normally.
Each string in peakHours has the form start end. A peak window is half-open: it includes start and excludes end. Pay earned during a peak window is doubled. Peak windows do not overlap.
Return the total pay in dollars after processing all events.
Function
calculateDasherPay(events: String[], peakHours: String[]) → doubleExamples
Example 1
events = ["06:15 ACCEPT A","06:18 ACCEPT B","06:36 FULFILL A","06:45 FULFILL B"]peakHours = []return = 14.4Pay is 3 * 0.30 = 0.90, then 18 * 0.60 = 10.80 while two deliveries overlap, then 9 * 0.30 = 2.70. The total is $14.40.
Example 2
events = ["06:15 ACCEPT A","06:18 ACCEPT B","06:19 ARRIVE A","06:22 PICKUP A","06:30 ARRIVE B","06:33 PICKUP B","06:36 FULFILL A","06:45 FULFILL B"]peakHours = []return = 12.6During 06:19-06:22 only order A contributes, and during 06:30-06:33 only order B contributes. All other intervals use the number of active deliveries, giving $12.60.
Example 3
events = ["06:15 ACCEPT A","06:18 ACCEPT B","06:19 ARRIVE A","06:22 PICKUP A","06:30 ARRIVE B","06:33 PICKUP B","06:36 FULFILL A","06:45 FULFILL B"]peakHours = ["06:20 06:30"]return = 18.0The ordinary total is $12.60. The base pay earned from 06:20 through 06:30 is $5.40, and peak time pays that amount once more, for $18.00.
Constraints
2 <= events.length <= 10000 <= peakHours.length <= 100- All times use valid same-day 24-hour
HH:MMnotation. - Events are in strictly increasing timestamp order.
- Every order has one
ACCEPTbefore its optionalARRIVEandPICKUPpair and one laterFULFILL. - All accepted orders are fulfilled by the final event.
- At most one store-wait interval is active at a time.
- Peak windows are valid, half-open, and non-overlapping.
More DoorDash problems
- Closest DashMartOA · PHONE SCREEN · Seen Jul 2026
- Maximize Total Profit by Assigning Chefs to DishesPHONE SCREEN · Seen May 2026
- Return Priority of Order IDsPHONE SCREEN · Seen Jun 2025
- Adjust Prices 🍱OA · Seen Oct 2024
- Discount EventsOA · Seen Oct 2024
- Team FormationOA · Seen Oct 2024
- Calculate Difference Value 🍧OA · Seen Mar 2024
- Get Sizes of Friends Groups 🥗OA · Seen Mar 2024