Flag Duplicate Card Authorizations Within a Time Window

Last updated: November 29, 2026

Quick Overview

Given card authorizations as (auth_id, timestamp, card_id, merchant_id, amount_cents) in any order, return the ids of authorizations that repeat the same card, merchant and amount within W seconds of the last accepted one with that key. Flagged authorizations do not reset the window.

N26
Coding & Algorithms
Software Engineer
N26
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given card authorizations as (auth_id, timestamp, card_id, merchant_id, amount_cents) in any order, return the ids of authorizations that repeat the same card, merchant and amount within W seconds of the last accepted one with that key. Flagged authorizations do not reset the window.

N26 card processing teams deal with merchants and terminals that retry authorizations, and double charges are a top source of support tickets. The interviewer wants to see a correct definition of the window, a hash keyed on the right tuple, and careful handling of ordering and ties.

What the Interviewer Expects
  • Clarify whether the window is anchored to the last accepted or last seen authorization
  • Sort by timestamp with a deterministic tie-breaker
  • Key a hash map on (card, merchant, amount)
  • Treat the boundary (exactly W seconds) consistently and say so
  • Analyse O(n log n) time due to sorting, O(n) space
Key Topics to Cover
hash maps
sliding window
sorting
stream processing
payments
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 do this on an unbounded stream with late-arriving events?
  • How do you evict stale keys so memory stays bounded?
  • What if a merchant legitimately charges the same amount twice, like two identical coffees?
  • How would you shard this across many workers?
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

An authorization is a duplicate if an earlier accepted authorization with the same (card_id, merchant_id, amount_cents) happened at most W seconds before it. Duplicates do not extend the window,...

High-Level Design

Sort by (timestamp, auth_id) so ties are deterministic. Keep last_ok[key] = timestamp of last accepted auth. For each auth, if a previous accepted one exists and ts - prev <= W, flag it. Otherwi...


Submit Your Answer
Markdown supported