Group GrabPay Accounts Into Rings by Shared Devices and Cards

Last updated: November 29, 2026

Quick Overview

Each account lists the device ids and payment card fingerprints it has used. Two accounts belong to the same ring if they share any device or any card, directly or through a chain of accounts; return every ring with more than one account.

Grab
Coding & Algorithms
Software Engineer
Grab
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Each account lists the device ids and payment card fingerprints it has used. Two accounts belong to the same ring if they share any device or any card, directly or through a chain of accounts; return every ring with more than one account.

Promo abuse and fraud rings are a core concern for Grab's GrabPay and GrabRewards teams, and this onsite style question checks whether you see the connected components hidden in the data. Interviewers look for union find (or graph BFS) and careful handling of identifier namespaces.

What the Interviewer Expects
  • Model accounts as nodes connected through shared identifiers
  • Use union find with path compression or BFS over an identifier index
  • Avoid O(n^2) pairwise comparison
  • Keep device ids and card ids in separate namespaces
  • Return deterministic, sorted output
Key Topics to Cover
Union find
Connected components
Hashing
Fraud detection
Graph modeling
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 support accounts being added incrementally in real time?
  • Some devices are shared by thousands of accounts (an internet cafe); how do you stop them from merging everything?
  • How would you compute ring size distribution at Grab's scale with Spark?
  • Why is deleting a link hard with union find, and what would you do instead?
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: list of (account_id, devices, cards). Output: groups of account ids that are connected through at least one shared identifier, only groups of size 2 or more, sorted by size descending then le...

High-Level Design

Comparing every pair of accounts is O(n^2). Instead, keep a map from each identifier to the first account that used it. When another account uses the same identifier, union the two accounts. Transitiv...


Submit Your Answer
Markdown supported

Related Questions