(customer_id, amount) occurring within 120 seconds. Write duplicates(payments) where each payment is (timestamp_seconds, customer_id, amount) sorted by time — return the list of indexes (into the input) flagged as duplicates of an earlier payment.duplicates([(0, 7, 500), (60, 7, 500), (300, 7, 500)])
[1]
The 60 s repeat is flagged; the 300 s one is a fresh charge.
Track last-seen time per (customer, amount) in a dict.
Update the timestamp even when flagged.