Your question is Detect Fraudulent Duplicate Charges. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
GEICO payment systems may receive repeated payment events caused by retries or duplicate submissions. Given an unsorted list of payment transactions, identify every pair of transactions that has the same customer, merchant, amount, and currency, and occurs within five minutes.
Return the matching pairs as zero-based index pairs referring to the original input order. A pair (i, j) is valid when i < j and the absolute timestamp difference is at most 300 seconds. Do not compare a transaction with itself. Return pairs sorted lexicographically.
Implement find_duplicate_charges(transactions). Each transaction is a dictionary with integer customer_id, integer merchant_id, integer amount_cents, string currency, and integer timestamp fields. Return a list of two-element lists, where each list contains the original indices of one potentially duplicated charge.
A transaction may match multiple other transactions. For example, three matching charges within five minutes produce all three pairs.
def find_duplicate_charges(transactions):