Back to problems

Match Payments to Invoices with a Forgiveness Range

Algorithm · Stripe · Hard

You are given a list of invoices and a list of payments, and you must pair every payment with an invoice when possible. Every invoice carries a unique invoice_id, a date written as YYYY-MM-DD, and a non-negative integer amount. Every payment carries a unique payment_id, an amount, and optionally an invoice_id (the character - means the payment names no invoice). Handle each payment on its own, using these rules: When the payment names an invoice_id, the only candidate is the…

Loading the rest of the question…