ongoingDeliveries * basePayRateThis problem should use List<String>, each activity record is represented as a string in the format:
orderId=<id>,action=<START|END>,time=<HH:MM>Example records:
orderId=O1,action=START,time=09:00orderId=O1,action=END,time=09:20START and one END record with the same orderId.[start, end] semantics: both start minute and end minute are included.start > end, that order contributes 0 minutes of payout.0.DasherPayoutService()
void addOrUpdatePayoutMetadata(String dasherId, int basePayRate, int bonusPay, int deliveryCountsToGetBonus)
basePayRate number of cents per minute that the dasher will get paid.void addDeliveryActivity(String dasherId, List<String> deliveryActivities)
deliveryActivities contains activity strings in the required format.int payout(String dasherId)
dasherId.1 ≤ dasherId.length() ≤ 1000 ≤ deliveryActivities.size() ≤ 100orderId=<id>,action=<START|END>,time=<HH:MM>00:00 ≤ time ≤ 23:59DasherPayoutService service = new DasherPayoutService()service.addOrUpdatePayoutMetadata(dasherId="D1", basePayRate=30, bonusPay=200, deliveryCountsToGetBonus=10)service.addDeliveryActivity(dasherId="D1", deliveryActivities=List.of("orderId=O1,action=START,time=09:00", "orderId=O1,action=END,time=09:10", "orderId=O2,action=START,time=09:20", "orderId=O2,action=END,time=09:30"))service.payout(dasherId="D1") = 660Explanation:
O1 runs from 09:00 to 09:10 using [start, end] semantics, so it contributes 11 minutes.O2 runs from 09:20 to 09:30, so it also contributes 11 minutes.11 + 11 = 22.22 * 30 = 660 cents.2, which is less than 10, so bonus = 0.660 cents.DasherPayoutService service = new DasherPayoutService()service.addOrUpdatePayoutMetadata(dasherId="D2", basePayRate=30, bonusPay=200, deliveryCountsToGetBonus=10)service.addDeliveryActivity(dasherId="D2", deliveryActivities=List.of("orderId=O10,action=START,time=09:00", "orderId=O10,action=END,time=09:20", "orderId=O11,action=START,time=09:10", "orderId=O11,action=END,time=09:30"))service.payout(dasherId="D2") = 1260Explanation:
09:00 to 09:09 = 10 minutes with 1 ongoing delivery → 10 * 30 = 300 cents.09:10 to 09:20 = 11 minutes with 2 ongoing deliveries → 11 * (2 * 30) = 660 cents.09:21 to 09:30 = 10 minutes with 1 ongoing delivery → 10 * 30 = 300 cents.300 + 660 + 300 = 1260 cents.2, so bonus = 0.1260 cents.DasherPayoutService service = new DasherPayoutService()service.addOrUpdatePayoutMetadata(dasherId="D3", basePayRate=25, bonusPay=150, deliveryCountsToGetBonus=2)service.addDeliveryActivity(dasherId="D3", deliveryActivities=List.of("orderId=O20,action=END,time=10:05", "orderId=O21,action=START,time=10:08"))service.addDeliveryActivity(dasherId="D3", deliveryActivities=List.of("orderId=O20,action=START,time=10:00", "orderId=O21,action=END,time=10:10"))service.payout(dasherId="D3") = 375Explanation:
O20 is reconstructed as 10:00 to 10:05 → 6 minutes.O21 is reconstructed as 10:08 to 10:10 → 3 minutes.6 + 3 = 9.9 * 25 = 225 cents.2, so bonus = 150 * 1 = 150 cents.225 + 150 = 375 cents.DasherPayoutService service = new DasherPayoutService()service.addOrUpdatePayoutMetadata(dasherId="D4", basePayRate=50, bonusPay=120, deliveryCountsToGetBonus=2)service.addDeliveryActivity(dasherId="D4", deliveryActivities=List.of("orderId=O1,action=START,time=08:00", "orderId=O1,action=END,time=08:00", "orderId=O2,action=START,time=08:10", "orderId=O2,action=END,time=08:10", "orderId=O3,action=START,time=08:20", "orderId=O3,action=END,time=08:20", "orderId=O4,action=START,time=08:30", "orderId=O4,action=END,time=08:30", "orderId=O5,action=START,time=08:40", "orderId=O5,action=END,time=08:40"))service.payout(dasherId="D4") = 490Explanation:
1 minute.5.5 * 50 = 250 cents.5.2 deliveries, so number of bonuses = floor(5 / 2) = 2.2 * 120 = 240 cents.250 + 240 = 490 cents.DasherPayoutService service = new DasherPayoutService()service.addOrUpdatePayoutMetadata(dasherId="D5", basePayRate=30, bonusPay=200, deliveryCountsToGetBonus=10)service.payout(dasherId="D5") = 0Explanation:
D5.0 delivery minutes and 0 completed deliveries.0 cents.