Skip to main content
All Questions

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 courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.