Implement a delivery cost tracker for drivers paid an hourly rate.
Unlock detailed company stats for this questionUpgrade
Drivers are paid a fixed hourly rate for the time they spend on deliveries. Implement:
- addDriver(driverId, hourlyRate): register a driver.
- recordDelivery(driverId, startTime, endTime): record a delivery. Its cost is (endTime - startTime) * hourlyRate.
- getTotalCost(): return the total cost of all deliveries recorded so far, in optimized time. Interviewers look for clean object-oriented design, correct data types for money, precision handling and time complexity. Some candidates saw it framed as a food delivery system, or with addDelivery instead of recordDelivery.
Expect follow-ups like
- Implement payUpToTime(time) to pay for all deliveries that ended at or before that time, without reprocessing every delivery each call.
- Implement getTotalUnpaidCost() to return the cost of deliveries not yet paid.
- Return the maximum number of drivers making deliveries at the same time in the last 24 hours.
- Why should money be stored as BigDecimal rather than float or double?
- How do real financial systems handle decimal numbers and rounding rules?
Format · A coding round, as a phone screen or a later technical round, built up in incremental parts. Candidates coded on HackerRank, and the interviewer ran test cases after each part. Several 2026 candidates were allowed to use AI tools such as Copilot or Cursor.
Also asked as · Implement a service that computes the total cost of all driver deliveries.; Design a delivery payment system that records driver deliveries and returns the total cost.; Design a driver delivery system that tracks driver hourly rates, assigned deliveries and total cost.
Community answers
No answers contributed by the community yet.
Related questions
Implement inorder traversal for an N-ary tree.Related courses

Course

Course
Course
