← 返回 stripe 的题目列表Six Degrees of Collusion - Direct Links
类型:online_judge
Problem: Directly Linked Users
Fraud actors may create many accounts and share identifiers such as devices, credit cards, or IP addresses. The first step is to find users who share the same physical device as a target user.
Given transaction logs transactions and a target_user, each log is formatted as:
user_id,device_id
Two different users are considered directly linked if they have used the exact same device_id.
Return all user IDs directly linked to target_user, sorted lexicographically. Do not include target_user itself.
Input Format
n
transaction_1
transaction_2
...
transaction_n
target_user
Output Format
Print the sorted user IDs separated by one space. Print an empty line if there are no linked users.
Constraints
0 <= n <= 2 * 10^5
user_id and device_id are non-empty strings without commas
A user may appear multiple times and may use multiple devices
Duplicate logs should not create duplicate outputs
Example
Input
5
Alice,D1
Bob,D1
Charlie,D2
David,D3
Eve,D1
Alice
Output
Bob Eve