Cluster Connected Accounts That Share Any Bank Account or Device
Last updated: November 29, 2026
Quick Overview
Each connected account lists identifiers it has used (bank account fingerprints, device ids, emails). Group accounts into clusters where two accounts belong together if they are linked by a chain of shared identifiers, and return the clusters sorted.
Stripe
November 29, 20260
0
0 solved
Each connected account lists identifiers it has used (bank account fingerprints, device ids, emails). Group accounts into clusters where two accounts belong together if they are linked by a chain of shared identifiers, and return the clusters sorted.
Platforms on Stripe Connect onboard many sellers, and fraud teams look for one actor operating several accounts through shared bank details or devices. The interviewer checks that you recognize transitive grouping as connected components, implement union-find with path compression, and keep output deterministic.
What the Interviewer Expects
- Recognize the problem as connected components over a bipartite account-identifier graph
- Map each identifier to the first account seen with it and union later accounts into it
- Implement union-find with path compression and union by size
- Produce sorted clusters so the output is stable for tests and review
- Discuss very common identifiers (a shared office Wi-Fi device) that would over-merge
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 exclude identifiers seen on more than some threshold of accounts?
- How would you support adding new accounts incrementally as they onboard?
- How would you explain to an analyst why two accounts ended up in the same cluster?
- How does this change if links have weights or confidence scores?
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: a dict account_id -> list of identifier strings. Output: list of clusters, each a sorted list of account ids, clusters sorted by their first element. Accounts with no shared identifiers form ...
High-Level Design
Index accounts 0..n-1. Keep owner[identifier] as the first account index that used it. For every later account using the same identifier, union the two. Afterwards group accounts by their root. Th...