AO
Back

Delivery Driver Payment System: Total Cost, Pay Up To, Max Concurrent Drivers

Also reported as Delivery Billing System · Food Delivery Billing System · Driver Payment Tracking

Phone ScreenPhone ScreenLast reported October 2026High Frequency

Problem Overview

The round: a phone screen (also reported as an onsite coding round): an in-memory payment system for a food-delivery platform, in three graded parts. Tens of thousands of drivers each have their own hourly rate, and a driver can run several deliveries at once. Several candidates passed with two parts working and the third talked through, though others were rejected after the same; one report says at least two parts are required. Reports from mid-2026 add a rate change to Part 1, and one of them also delivery ids and a 3-hour cap.

Given — what the tests call

The class name and the snake_case names are our setup (reports use both addDriver and add_driver); ask your interviewer:

class DeliverySystem:
    def __init__(self): ...
    # Part 1
    def add_driver(self, driver_id, usd_hourly_rate): ...
    def record_delivery(self, driver_id, start_time, end_time, delivery_id=None): ...
    def update_driver_rate(self, driver_id, new_rate, effective_time): ...
    def get_total_cost(self): ...
    # Part 2
    def pay_up_to(self, pay_time, prorate=False): ...
    def get_total_cost_unpaid(self): ...
    # Part 3
    def max_simultaneous_drivers_in_past_24_hours(self, now): ...

Times are Unix epoch seconds (integers). A delivery pays rate * (end_time - start_time) / 3600; for example $10.00 an hour for 1h30m is $15.00. The tests print every amount with two decimals, so returning a float, a Decimal or a two-decimal string all pass.

Part 1 — total cost, rate changes, money

  • add_driver(driver_id: int, usd_hourly_rate: float) registers a driver; record_delivery(driver_id: int, start_time: int, end_time: int, delivery_id: str = None) records a finished delivery; get_total_cost() returns the cost of every delivery recorded so far.
  • A driver's overlapping deliveries are each paid on their own.
  • get_total_cost() feeds a live dashboard and may be called in a loop: make it fast (the written prompt calls amortised O(1) per call ideal).
  • Money: keep each delivery's fractions of a cent and round only the total. At $15.15 an hour, 1.5 hours ($22.725) plus 0.5 hours ($7.575) is $30.30; rounding each delivery first gives $30.31.
  • Mid-2026 version, also graded: update_driver_rate(driver_id: int, new_rate: float, effective_time: int) changes the rate from effective_time on. A whole delivery is priced at the rate in effect when it started, and a delivery already recorded is never re-priced. record_delivery ignores a repeated delivery_id, and a delivery longer than 3 hours is ignored (exactly 3 hours counts). In that report delivery_id is the first argument and the total is returned as a two-decimal string; here it is a keyword, so both versions run with one class.

Part 2 — pay up to a time

  • pay_up_to(pay_time: int, prorate: bool = False) marks as paid every delivery that ended by pay_time (end_time <= pay_time). It may be called many times with later times; calling it again with the same or an earlier time must not pay anything twice.
  • get_total_cost_unpaid() returns what is still unpaid. get_total_cost() keeps returning everything ever recorded, paid or not.
  • Clarify first: another report pays the hours already worked on an unfinished delivery ("working 12-10pm, pay up until 5pm"). That reading is prorate=True; one test checks each reading.

Part 3 — most drivers at once in the past 24 hours

  • max_simultaneous_drivers_in_past_24_hours(now: int) returns the largest number of distinct drivers (not deliveries) delivering at the same instant within [now - 24h, now).
  • A driver with overlapping deliveries counts once. Intervals are half-open, so a delivery ending at the second another starts does not overlap it.
  • One report was also asked to return when the maximum happened; the written prompt calls that optional, and it is not graded here.

Follow-up Arc

Interviewers escalate through these phases. The order varies, but most candidates see at least one from each bucket.
Trade-off discussion · 12
Trade-off discussion

get_total_cost is called very often, even inside a loop. How do you make it fast? (when: Part 1; one interviewer pushed hard on caching, then asked more follow-ups on caching and prefix sums. The written prompt calls amortised O(1) per call ideal)

What is the time and space complexity of each method you wrote?

Probes for: Throughout; several reports say every method was asked

How do you handle start_time and end_time: what type, what precision?

Probes for: Part 1; two candidates were asked this directly

What type do you use for money, and when do you round?

Probes for: Part 1; one interviewer required double with two correct decimals, another said cents must keep their fractional part

Why did you choose this data structure?

Probes for: Reported in an onsite round and an AI-assisted round

If a driver's rate changes while a delivery is in progress, which rate applies?

Probes for: Mid-2026 version with update_driver_rate; the rate at the delivery's start applies to the whole delivery

How do you make pay_up_to efficient when it is called again and again, without paying anything twice?

Probes for: Part 2; one candidate was only asked how to optimise it, with no code required

Does paying up to a time include the hours already worked on a delivery that has not finished?

Probes for: Part 2; one report's version pays up to the time, the written prompt pays only finished deliveries

What is the largest number of drivers delivering at the same time in the past 24 hours: drivers or deliveries?

Probes for: Part 3

Also return the time span when the maximum held.

Probes for: Part 3, one report; the written prompt calls it optional

If you had more time, how would you keep debugging the tests that still fail?

Probes for: End of a mid-2026 round

Walk me through the code the AI wrote: why does it work, and what would you improve?

Probes for: AI-assisted rounds

Approach Trade-offs

Approaches actually attempted in reports — including ones that lost candidates time. Pick deliberately.
ApproachNotes
Money: keep amounts exacta Fraction, or a Decimal at full precision) and round only the total. One report notes that switching to Decimal does not fix anything if you quantize each delivery to the cent.
pay_up_to: the written prompt suggests a min-heap by end time. One candidate proposed an ordered list per driver with binary search and running sums—
their AI assistant proposed a list with a pointer, and they discussed the trade-off.—
Part 3: the written prompt recommends merging each driver's deliveries, then a sweep line over the merged spans—
one onsite candidate used a sweep line.—

What Reports Emphasize

Common mistakes: Rounding each delivery to the cent before adding it up. A mid-2026 report shows $30.31 instead of $30.30 ($15.15 an hour for 1.5 hours plus 0.5 hours), and that candidate's AI assistant suggested exactly this; another candidate's total was two cents off until the interviewer gave a hint.; Storing whole cents: one interviewer said cents must keep their fractional part.; Converting dollars to cents by dividing by 100 instead of multiplying. One candidate lost most of Part 1 to it; the interviewer saw the bug and let them find it.; Pricing a delivery with the driver's latest rate when it is recorded, instead of the rate in effect when it started (mid-2026 version).; Counting deliveries instead of drivers in Part 3 (two reports warn about this).; Processing a start before an end at the same timestamp in the Part 3 sweep (one report).; Blaming rounding for every wrong total: in one round a $35.10 gap was one delivery billed twice.

Interviewer hints: One interviewer stressed that the total is computed very often, even in a loop, so caching matters; the written prompt calls amortised O(1) per call ideal.; One interviewer required double with two correct decimals and would not accept BigDecimal; that candidate hit precision issues and solved two of the three parts.; Two interviewers asked specifically how start and end times are handled.; Interviewers ask for the complexity of every method and why you chose each data structure.; In AI-assisted rounds, interviewers check that you understand the code the AI wrote.

What passers do: Several candidates passed with Parts 1 and 2 working and Part 3 talked through, but others were rejected after the same; one report says at least two parts are required.; One candidate who passed without AI wrote the base part and both follow-ups.; In an AI-assisted onsite, one candidate discussed their understanding, an example and the approach with the interviewer first, and only then had the AI implement it.; One candidate who passed the screen kept a hashmap of drivers and a running total, and explained the complexity.

Why people fail: Running out of time: one candidate blamed constant interruptions from the interviewer, others lost Part 1 to bugs.; Practising a Part 3 that differed from what the interviewer asked.; Fighting the tools in AI rounds: one candidate says HackerRank's built-in AI slowed them down, another had screen sharing break in a browser Zoom.; One candidate guesses that an AI-assisted round needs all three parts; that is their guess, not something they were told.

Edge cases probed: A driver's overlapping deliveries, each paid on its own.; pay_up_to called again with the same or an earlier time must not pay twice.; A delivery ending exactly at the pay time: the written prompt says end <= time, another candidate described end < time.; Mid-2026 version: a repeated delivery id, a delivery over 3 hours, a delivery that crosses a rate change. That round's tests covered several drivers, repeated ids, fractional amounts, overlapping deliveries and rate changes.; A total that lands exactly on half a cent: the report that gives the rounding rule says half up versus half to even was never confirmed.

Practice

Write your own against 12 test cases, or read the worked solution — approach, complexity, and code that runs.

Prepping for Rippling with friends?

Send them this page. It is free to read, no account needed.

Free preview

Every question in the Rippling catalog gets this depth

What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 17 Rippling questions, refreshed monthly from new candidate reports.

$59/mo — or $50/mo with the 3-month pass · cancel anytime
Rippling · Phone Screen · Reported 32× across candidate reports
Is this helpful?