Flag Duplicate Payment Instructions Within a Time Window
Last updated: November 29, 2026
Quick Overview
Given a time-ordered stream of payment instructions, return the IDs of instructions that repeat the same debit account, beneficiary, amount and currency within a configurable number of seconds of the previous identical one.
Citi
November 29, 20260
0
0 solved
Given a time-ordered stream of payment instructions, return the IDs of instructions that repeat the same debit account, beneficiary, amount and currency within a configurable number of seconds of the previous identical one.
Corporate clients sometimes upload the same payment file twice or retry an API call, and a bank must hold the duplicate before money leaves. A phone screen uses this to see whether you pick the right key and data structure quickly and reason about what counts as a duplicate.
What the Interviewer Expects
- Define a duplicate key from the business fields, not the payment ID
- Use a hash map from key to last timestamp
- Compare against the window and update the last-seen time
- Handle amounts as integer minor units
- State O(n) time and the memory growth concern
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you bound memory if the stream runs forever?
- What changes if events arrive out of order by up to 5 seconds?
- Should a flagged duplicate reset the window, and why might operations prefer one rule over the other?
- How would this run across many service instances?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Each instruction is (payment_id, ts, debit_acct, beneficiary_acct, amount_cents, ccy), sorted by ts. An instruction is a suspected duplicate if an earlier instruction with the same four business f...
High-Level Design
The payment ID is useless for this check because a resubmitted file gets fresh IDs. The key is (debit, beneficiary, amount, currency). Keep a dictionary from key to the timestamp of the most recent ...