Group Accounts Sharing Devices or Emails Into Fraud Rings
Last updated: November 29, 2026
Quick Overview
Each account has a list of identifiers (device fingerprints, emails, card hashes). Two accounts are linked if they share any identifier, and links are transitive. Return all groups of at least two linked accounts, largest first.
PayPal
November 29, 20260
0
0 solved
Each account has a list of identifiers (device fingerprints, emails, card hashes). Two accounts are linked if they share any identifier, and links are transitive. Return all groups of at least two linked accounts, largest first.
PayPal's risk teams link accounts through shared devices, funding instruments and contact details to uncover coordinated abuse. The interviewer wants a union-find solution that avoids comparing every pair of accounts, plus a sensible discussion of hub identifiers that would merge everything.
What the Interviewer Expects
- Map each identifier to the first account that used it
- Use union-find with path compression and union by size
- Avoid O(n^2) pairwise comparison
- Return deterministic, sorted output
- Discuss super-connector identifiers such as shared office Wi-Fi devices
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you handle an identifier shared by 50,000 accounts (a public library computer)?
- How would you support new accounts arriving continuously?
- How would you also return which identifiers connect each ring?
- How would you do this in Spark over hundreds of millions of accounts?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: accounts maps account id to a list of (type, value) identifiers. Output: a list of rings, each a sorted list of account ids, containing only rings of size >= 2, ordered by size descending t...
High-Level Design
Treat accounts as nodes. Instead of building edges between every pair of accounts that share an identifier (quadratic for a popular device), keep an owner map from identifier to the first account se...