Flag Duplicate GrabPay Charges Within a Time Window

Last updated: November 29, 2026

Quick Overview

Given a list of GrabPay transactions (id, user, merchant, amount in cents, timestamp in seconds), return the ids of transactions that repeat the same user, merchant and amount within `window` seconds of the previous matching transaction.

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

0

0

0 solved


Given a list of GrabPay transactions (id, user, merchant, amount in cents, timestamp in seconds), return the ids of transactions that repeat the same user, merchant and amount within `window` seconds of the previous matching transaction.

A warm-up in the style of Grab's phone screens for payments teams, where double charges from retried taps or flaky mobile networks in Southeast Asia are a real support cost. The interviewer checks that you pick the right hash key, process events in time order, and state precisely what 'within the window' means.

What the Interviewer Expects
  • Clarify whether the window compares against the previous match or the first in a burst
  • Sort by timestamp before scanning instead of assuming input order
  • Use a composite hash key of user, merchant and amount
  • Run in O(n log n) or O(n) if already sorted
  • Handle ties in timestamp deterministically
Key Topics to Cover
Hash maps
Composite keys
Event ordering
Time windows
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 do this on an unbounded stream with limited memory?
  • What changes if amounts can differ slightly because of currency rounding?
  • How would you avoid flagging legitimate repeat purchases such as two coffees?
  • How would you shard this check across many payment service instances?
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: tuples (txn_id, user, merchant, amount, ts), possibly unsorted. Output: ids of transactions that match an earlier transaction on (user, merchant, amount) with ts - prev_ts <= window. I co...

High-Level Design

Sort by timestamp (tie-break by id so output is stable). Keep a dictionary from the composite key to the last timestamp seen. For each transaction, if the key exists and the gap is within the window, ...


Submit Your Answer
Markdown supported

Related Questions