Group Accounts Sharing Devices or Phones for Fraud Review
Last updated: November 29, 2026
Quick Overview
Each account lists identifiers such as device fingerprints, phone numbers and emails. Two accounts are linked if they share any identifier, directly or through a chain of other accounts. Return every linked cluster of two or more accounts, largest first.
SoFi
November 29, 20260
0
0 solved
Each account lists identifiers such as device fingerprints, phone numbers and emails. Two accounts are linked if they share any identifier, directly or through a chain of other accounts. Return every linked cluster of two or more accounts, largest first.
Fraud and risk teams at SoFi look for rings of accounts opened with shared devices or contact details, for example to abuse sign-up bonuses or apply for multiple loans. This onsite question checks union find with path compression, careful identifier normalization, and awareness of how the approach scales.
What the Interviewer Expects
- Maps each identifier to the first account that used it and unions later users with it
- Implements union find with path compression and union by size
- Normalizes identifiers (case, whitespace) before comparing
- Filters out singleton accounts and sorts output deterministically
- Discusses near-linear complexity and the alternative of BFS on a bipartite graph
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 prevent a shared public device such as a library computer from merging thousands of accounts?
- How would you update clusters incrementally as new accounts are created?
- How would you weight links so a shared email counts more than a shared IP?
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: dict account_id -> list of identifier strings. Linking is transitive. Output: list of clusters, each a sorted list of account ids, only clusters with at least two accounts, ordered by size de...
High-Level Design
Rather than comparing every pair of accounts (O(n^2)), treat identifiers as hubs. Keep first_owner[identifier]; when another account presents the same identifier, union the two accounts. Union find ...