As reported: Rippling technical / phone screen, asked again and again from 2025 to 2026 (SDE-2 London Jul 2026; Senior SWE USA Oct 2026; Senior SWE Oct 2025; SDE-2 Aug 2025; SDE-2 India 2025; Senior SWE Bengaluru May 2025). 60 minutes on HackerRank (or CoderPad-style), one interviewer, sometimes a shadow; no starter code — you define the classes and functions and show sample calls in
main(). AI help (Copilot, ChatGPT, or HackerRank's built-in agent in late 2026) was allowed in most rounds if declared, opt-in in one, with different evaluation; generated code that adds needless decimal places or unoptimized code costs time. The problem comes in three parts: (1)addDriver,addDelivery/recordDelivery(driverId, startTime, endTime)andgetTotalCost(), wheregetTotalCostmust be fast (keep a running total at insertion instead of anO(n)scan); (2)payUpToTime(upToTime)andgetCostToBePaid()/getTotalCostUnpaid()— unpaid = total − paid, anO(n)scan was pushed toward something better; (3) analytics: the maximum number of drivers active at the same time in the last 24 hours, often only discussed (sort, then check overlaps). Interviewers ran their own test cases after each part. Money precision is the recurring trap: interviewers expectedBigDecimalrather thanfloat/doubleand asked why, a test expecting0failed on0.005, small rounding errors at per-second granularity and pro-rata costs were flagged, and one interviewer asked how real financial systems round. Other discussion points: makinggetTotalCostO(1), historical driver rates, and how a rate change with an effective timestamp affects deliveries (a late-2026 round spent its time debugging this). In an SDE-1 onsite DSA round (Feb 2026) the same idea came as aTravelclass: drivers with hourly rates, trips booked by start and end time and assigned to the earliest available driver, the cost of one trip and the total so far, then the minimum number of drivers needed at a given instant. Several candidates ran out of time on part 3; one reached an offer.
A food-delivery company pays its drivers by the hour. Build DeliveryCostTracker:
addDriver(driverId, hourlyRate)— register a driver;hourlyRateis in dollars, as a decimal string such as"18.50".recordDelivery(driverId, startTime, endTime)— the driver made a delivery fromstartTimetoendTime(seconds). It costshourlyRate × (endTime − startTime) / 3600dollars.getTotalCost()— the cost of every delivery recorded so far, in dollars.payUpTo(payTime)— pay every recorded delivery that ended at or beforepayTimeand is not paid yet.getTotalCostUnpaid()— the cost of the recorded deliveries that are not paid yet.getMaxActiveDriversInLast24Hours(currentTime)— the largest number of drivers on a delivery at the same instant, over the instantstwithcurrentTime − 86400 ≤ t ≤ currentTime.
Money is returned as a string with exactly two decimals, rounded half up to the cent from the exact amount (round once, at the end — never per delivery).
Example
addDriver(1, "18.00")
addDriver(2, "24.50")
recordDelivery(1, 0, 3600) # 18.00
recordDelivery(2, 1800, 5400) # 24.50
getTotalCost() → "42.50"
payUpTo(3600) # driver 1's delivery ended at 3600: paid
getTotalCostUnpaid() → "24.50"
recordDelivery(1, 4000, 4600) # 10 minutes: 3.00
getTotalCost() → "45.50"
getTotalCostUnpaid() → "27.50"
getMaxActiveDriversInLast24Hours(5000) → 2 (both drivers were out between 1800 and 3600)
Constraints: at most 2·10^5 calls in total and at most 500 calls to getMaxActiveDriversInLast24Hours (with at most 10^4 deliveries when it is called); driver ids are distinct integers in [1, 10^6]; rates are decimal strings with at most two decimals in [0.01, 1000]; times are integers in [0, 2·10^9]; startTime < endTime ≤ startTime + 10800 (at most 3 hours); every delivery belongs to a driver added earlier; the payTime values never decrease.
Code runner format: one call per line — ADD_DRIVER id rate, RECORD id start end, TOTAL, PAY t, UNPAID, MAX_ACTIVE t — and the harness prints the result of every TOTAL, UNPAID and MAX_ACTIVE on its own line. Implement the class with the six methods above (in Go: NewDeliveryCostTracker() and exported method names).
Clarifications
- Deliveries may be recorded in any time order, and a driver may run several deliveries at once; each one is paid in full.
- A driver is active at instant
twhen one of their deliveries hasstartTime ≤ t < endTime; a driver with two overlapping deliveries counts once. A delivery ending attand another starting attdo not overlap. payUpTopays only deliveries already recorded. A delivery recorded later stays unpaid until a laterpayUpTocovers its end time, even if it ended before an earlierpayTime.- Tests never land exactly on a half cent, but amounts are sums of many fractional cents: accumulate exactly.
Follow-ups
- How do real financial systems store money and decide when and how to round?
- A driver's rate can change, with an effective timestamp. How do existing and future deliveries pick their rate, and what does the data model need (historical rates)?
- Make
getTotalCostO(1), and payouts better than a scan over every delivery.