Question bank › Hashing
Dsa Hashing Easy

Transaction Deduplicator

You are processing financial transactions. To prevent double-billing, a transaction is considered a duplicate if it has the same 'Sender ID' and 'Amount' as a previous transaction that occurred within 60 seconds (inclusive). Given N transactions sorted by timestamp, output the count of non-duplicate (valid) transactions. Input Format: - Line 1: Integer N. - Next N lines: 'timestamp amount sender_id' (timestamp is integer seconds). Output Format: - Integer count of valid transactions. Example: Input: 3 0 100 user1 40 100 user1 80 100 user1 Output: 2 (Explanation: T1(0) is valid. T2(40) is a duplicate of T1. T3(80) is valid because the only previous valid transaction (T1) was 80s ago, and the last transaction (T2) was ignored or outside the window of T3's check—actually, the rule is any transaction within 60s. Wait: If T2 is a duplicate, we ignore it. T3(80) is valid because T2(40) is the only one within 60s, but we only skip if it matches *any* previous within 60s. So T2 matches T1. T3 matches T2.)

Key concepts

hashingsimulationtime-window

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.