Problem · Graph
Fraud Ring Size
Learn this problemProblem statement
Direct links alone may miss sophisticated fraud rings. A fraud ring is the full set of users connected by any chain of shared identifiers.
Each transaction log entry is formatted as user_id,device_id,credit_card. Two users are connected if they share a device or a credit card, either directly or through other connected users.
Given the log and a target user, return the number of unique users in the fraud ring containing the target user. Include the target user in the count.
Function
getFraudRingSize(transactions: String[], targetUser: String) → intComplete getFraudRingSize.
String transactions[n]: transaction rows formatteduser_id,device_id,credit_cardString targetUser: the user to investigate
Returns
int: the fraud ring size.
Examples
Example 1
transactions = ["Alice,D1,CC1","Bob,D1,CC2","Charlie,D2,CC2","David,D3,CC3","Eve,D3,CC4"]targetUser = "Alice"return = 3Alice connects to Bob by device D1, and Bob connects to Charlie by card CC2. David and Eve are in a separate cluster.
Example 2
transactions = ["A,D1,C1","B,D2,C2","C,D3,C3"]targetUser = "A"return = 1No other user shares A's identifiers.
Constraints
- 0 <= transactions.length <= 10^5
- User IDs, device IDs, and credit-card hashes contain no commas.
More Stripe problems
- Deployment Window SchedulerOA · Seen Jul 2026
- Directly Linked UsersOA · Seen Jun 2026
- Risky Fraud RingOA · Seen Jun 2026
- Account Balance Manager Part 3 - Platform CoverageONSITE INTERVIEW · Seen Jun 2026
- BitFont Part 3 - Decode Run-Length-Encoded RowsONSITE INTERVIEW · Seen Jun 2026
- Record Linkage Part 3 - Full Connected ComponentPHONE SCREEN · Seen Jun 2026
- Shipping Cost Calculator Part 3 - Mixed Fixed/Incremental TiersONSITE INTERVIEW · Seen Jun 2026
- Transaction Fee Calculator - Per-Merchant Volume DiscountPHONE SCREEN · Seen Jun 2026