Company: Stripe
Difficulty: medium
Fraud Ring Size 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. Identifier kinds are independent: a device id and a credit-card hash that happen to be the same text are two different identifiers and do not link anyone. If the target user never appears in the log, their fraud ring is just themselves, so the answer is 1 . Function getFraudRingSize(transactions: String[], targetUser: String) -> int Complete getFraudRingSize . String transactions[n] : transaction rows formatted user_id,device_id,credit_card String targetUser : the user to investigate Returns int