AlgoMaster Logo

Delivery Ledger: Solution Walkthrough

High Priority23 min readUpdated November 11, 2026

Delivery Ledger is a small codebase that tracks how much a courier company owes its drivers. Drivers log their deliveries, their hourly rates can change over time, and payroll processes payments up to a specified point in time.

The interview lasts 60 minutes and is divided into four phases:

  • Phase 0: Understand the code (10 minutes). Fill in three missing values in a test file and answer three questions about the existing implementation.
  • Phase 1: Fix a bug (10 minutes). Fix a payroll bug that applies a driver's new hourly rate to work completed before the rate change.
  • Phase 2: Add a feature (20 minutes). Implement pay_up_to(time) and unpaid() while following five payment rules defined in the README.
  • Phase 3: Improve performance (20 minutes). Optimize the code for a dashboard that calls total_cost() and unpaid() after almost every event, with tests scaling to 2,000 drivers and 400,000 requests (6,000 drivers and 1,000,000 requests in Java, C# and C++).

Phases 1 and 2 require relatively little code, but the challenge is handling several payment rules correctly at the same time. Time intervals are half-open, overlapping deliveries must be paid only once, rounding happens once per driver, and a payment can cover part of a delivery.

The tricky part is that most incorrect implementations in this exercise still pass all the visible tests while breaking one of these rules. Hidden tests check each rule separately, so work out the edge cases before prompting the assistant, and always test the generated code before moving on.

Premium Content

Subscribe to unlock full access to this content and more premium articles.