Flag Duplicate Wire Transfers Inside a Rolling Time Window
Last updated: November 29, 2026
Quick Overview
Given a time-ordered stream of wire transfers (timestamp, sender, beneficiary, amount), return the indices of transfers that repeat the same sender, beneficiary and amount within W seconds of an earlier matching wire.
J.P. Morgan
November 29, 20260
0
0 solved
Given a time-ordered stream of wire transfers (timestamp, sender, beneficiary, amount), return the indices of transfers that repeat the same sender, beneficiary and amount within W seconds of an earlier matching wire.
This is the kind of warm-up J.P. Morgan uses on its HackerRank-style online assessment for Corporate and Investment Bank and payments teams, framed around duplicate-payment controls that operations teams really run. The interviewer checks whether you pick a hash map keyed on the right tuple and expire stale timestamps cleanly instead of scanning all prior wires.
What the Interviewer Expects
- Key the lookup on the full (sender, beneficiary, amount) tuple, not on one field
- Expire timestamps older than the window so memory tracks only live wires
- State whether the window boundary is inclusive and keep it consistent
- Use integer cents for amounts rather than floats
- Reach O(n) amortized time over the stream
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 change this if wires arrive slightly out of order, say up to 5 seconds late?
- What if near-duplicates (same parties, amounts within 1%) should also be flagged?
- How would you run this across many processes partitioned by sender?
- How would you bound memory when one sender sends millions of identical small payments?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input is a list of (ts, sender, beneficiary, amount_cents) sorted by ts. A wire is a duplicate if an earlier wire with the same sender, beneficiary and amount happened at most W seconds before i...
High-Level Design
Keep a map from the key tuple to a deque of recent timestamps for that key. For each wire, pop timestamps from the front of its deque that fall outside the window, then the wire is a duplicate exactly...