← Questions

Payment ledger with partial refunds and date queries

0
StripeCodingLast asked Apr 2026

Build a small payment ledger driven by text commands:

  • record a payment with an ID, a UTC timestamp and an amount, rejecting a malformed timestamp or a duplicate ID;
  • refund part or all of a payment, any number of times, never more than it was worth in total;
  • report net revenue (payments minus refunds);
  • list the IDs of payments made on a given date, or between two dates, in the order they were recorded, rejecting malformed dates.

Return one result for each command. A fully refunded payment still shows up in date queries. Think about how to index payments by date so the queries don't scan everything.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding