Fraud Ring Size
Updated
Problem statement
Stripe Fraud Ring Tasks
This problem is Task 2 of 3 in the Stripe fraud-ring sequence.
- Task 1: Directly Linked Users
- Task 2: Fraud Ring Size (current)
- Task 3: Risky Fraud Ring
Direct links alone are insufficient for detecting sophisticated fraud rings, as bad actors may rotate devices to avoid simple detection logic. However, they often still share financial instruments.
A Fraud Ring is the full set of users connected by any chain of shared identifiers. If User A shares a device with User B, and User B shares a credit card with User C, then User A and User C are part of the same coordinated ring.
The goal is to quantify the size of the threat. Each transaction includes a user ID, a device ID, and a credit-card hash. Given a target user, calculate the total number of unique users within that user's extended Fraud Ring.
Input
transactions: a list of strings, where each string is formatted asuser_id,device_id,credit_card.targetUser: the user ID to investigate.
Note: A single user may appear multiple times in the transaction log with different identifiers. For example, if Alice uses Device A and Device B, she links those two devices together. Anyone on Device A is therefore connected to anyone on Device B through Alice.
Output
Return the number of unique users in the Fraud Ring containing targetUser, including targetUser.
Function
getFraudRingSize(transactions: String[], targetUser: String) → intExamples
Example 1
transactions = ["Alice,D1,CC1","Bob,D1,CC2","Charlie,D2,CC2","David,D3,CC3","Eve,D3,CC4"]targetUser = "Alice"return = 3Alice used Device D1. Bob also used Device D1, linking Alice and Bob.
Bob used Credit Card CC2. Charlie also used Credit Card CC2, linking Bob and Charlie.
David is on Device D3 and Card CC3, sharing no overlap with the Alice—Bob—Charlie cluster. Eve is on Device D3, linking Eve to David, but they remain disjoint from Alice.
The extended ring containing Alice consists of {Alice, Bob, Charlie}, resulting in a size of 3.
Example 2
transactions = ["A,D1,C1","B,D2,C2","C,D3,C3"]targetUser = "A"return = 1No other user shares an identifier with A, so its Fraud Ring contains only A.
Constraints
1 <= transactions.length <= 10^5.- Every transaction contains exactly three non-empty, comma-free fields:
user_id,device_id, andcredit_card. targetUserappears in at least one transaction.- A user may appear in multiple transactions, and every occurrence represents the same user.
More Stripe Online Assessment questions
- Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
- Chat Billing CalculationOA · Seen Nov 2026
- Deployment Window SchedulerOA · Seen Nov 2026
- Asynchronous Event ProcessingOA · Seen Nov 2026
- Subscription and Usage-Based Billing CalculatorOA · Seen Nov 2026
- Split Tender Part 4 - RefundsOA · PHONE SCREEN · Seen Nov 2026
- Request Routing SystemOA · Seen Nov 2026
- Incident MonitorOA · Seen Nov 2026
- Split Tender Part 3 - SurchargesOA · Seen Nov 2026
- Split Tender Part 2 - Expiration DatesOA · Seen Nov 2026
Similar questions at other companies
- Find Minimum City HopsAmazon · OA
- Shortest Path from Encoded Graph EdgesBitGo · OABitGo interview questions
- Race a Friend to a Shared HomeIntuit · OAIntuit interview questions
- Shortest Route Through a Traced MazeDuolingo · OADuolingo interview questions
- Word Chain Jumps in a GridGoogle · PHONE SCREENGoogle interview questions
- Hierarchical Permission CheckeBay · ONSITE INTERVIEWeBay interview questions
- Route Graph Reachability with a Broken LinkFigma · PHONE SCREENFigma interview questions
- Minimum Currency ConversionsEPAM · PHONE SCREENEPAM interview questions
- Finite Web CrawlerMongoDB · PHONE SCREEN · ONSITE INTERVIEWMongoDB interview questions
- Currency Conversion RateBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
Stripe interview experiences
- Stripe SWE Onsite over Two Days: 1 Experience
- Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences
- Stripe AI Coding Interview, Experienced SWE: 6 Experiences
- Stripe SWE Intern Payout Scheduler Phone Screen: 1 Experience
- Stripe New Grad SWE Onsite and HM Round: 1 Experience
- Stripe Experienced MLE Phone Screens: 1 Experience