Flag Duplicate Card Charges Within a Sixty Second Window

Last updated: November 29, 2026

Quick Overview

Given a time-ordered stream of card transactions (id, card, merchant, amount in minor units, timestamp in seconds), return the ids of transactions that repeat the same card, merchant and amount within 60 seconds of the previous matching charge.

Revolut
Coding & Algorithms
Software Engineer
Revolut
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a time-ordered stream of card transactions (id, card, merchant, amount in minor units, timestamp in seconds), return the ids of transactions that repeat the same card, merchant and amount within 60 seconds of the previous matching charge.

Revolut's early coding screens favour short problems drawn from card payments, and accidental double charges at a terminal are a real support driver. The interviewer checks that you pick the right hash key, compare against the most recent match rather than the first, and keep money as integers.

What the Interviewer Expects
  • Clarify whether the window is inclusive and whether input is sorted by time
  • Use a hash map keyed by (card, merchant, amount) storing the last timestamp
  • Run in a single O(n) pass with no nested loops
  • Represent amounts in minor units to avoid float comparison bugs
  • Explain why the stored timestamp is updated even when a charge is flagged
Key Topics to Cover
hash maps
sliding time window
stream processing
card payments
idempotency
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you handle transactions arriving slightly out of order, up to 5 seconds late?
  • How do you bound memory when the stream runs for days?
  • What changes if amounts may differ by a currency conversion rounding of 1 minor unit?
  • How would you return the original charge each duplicate points at?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input is a list of tuples (tx_id, card, merchant, amount, ts) sorted by ts. A charge is a duplicate if an earlier charge with the same card, merchant and amount happened at most 60 seconds before ...

High-Level Design

Only the most recent matching charge matters: if any earlier match is within 60 seconds, the latest one is too, because input is sorted. So keep last_seen[(card, merchant, amount)] = ts and compare ...


Submit Your Answer
Markdown supported