Record Linkage Part 3 - Full Connected Component
Updated
Problem statement
This continues the record-linkage problem. You get a list of user records, a weight for each field, a similarity threshold and a target record. Return every record that is connected to the target, either directly or through a chain of other records.
Inputs:
rowsis aString[]. Each row has the form"id,name,email,company".weightsis aString[]of"field,weight"entries. Each field is one of name, email or company, and the weights add up to 1.thresholdis the similarity two records need to be linked.targetIdis the id of the target record.
To compare two records, look at each field. Every field that matches in both records adds its weight to their similarity. Two records are linked when their similarity is >= threshold.
Linkage is transitive. If A links to B and B links to C, then A, B and C are all in the same group, even when A and C are not linked directly. The records you can reach from the target through any chain of links form its connected component.
Return the ids of every record in the same connected component as targetId, leaving out the target itself. Return them as an int[] sorted in ascending order.
Function
findLinkedComponent(rows: String[], weights: String[], threshold: float, targetId: int) → int[]Examples
Example 1
rows = ["1,Alice,alice@gmail.com,Stripe", "2,Alicia,alice@gmail.com,Stripe", "3,Alice,alice@yahoo.com,Google", "4,Bob,bob@gmail.com,Stripe"]weights = ["name,0.2", "email,0.5", "company,0.3"]threshold = 0.5targetId = 1return = [2]Record 1 links directly to record 2 (similarity 0.8). Record 2 does not link to record 3 (0) or record 4 (0.3 < 0.5), and record 1 links to neither 3 nor 4. So the component of record 1 is {1, 2}; excluding the target, the answer is [2].
Example 2
rows = ["1,Alice,alice@gmail.com,Stripe", "2,Alicia,alice@gmail.com,Stripe", "3,Bob,bob@yahoo.com,Google", "5,Alicia,carol@outlook.com,Stripe"]weights = ["name,0.2", "email,0.5", "company,0.3"]threshold = 0.5targetId = 1return = [2, 5]Record 1 links to record 2 (email + company match = 0.8). Record 2 links to record 5 (name 'Alicia' + company 'Stripe' match = 0.2 + 0.3 = 0.5 >= threshold), but record 5 does NOT link directly to record 1 (only company matches = 0.3 < 0.5). Transitivity pulls record 5 into record 1's component via record 2. Record 3 links to nobody. Component of 1 = {1, 2, 5}; excluding the target, the answer is [2, 5].
Constraints
- Each row is
"id,name,email,company", and the id is an integer. - Each weight entry is
"field,weight", where the field is name, email or company. The weights add up to 1. - The similarity of two records is the sum of the weights of the fields that match. Two records are linked when their similarity is
>= threshold. - Linkage is transitive, so the answer is the whole connected component of the target, not only its direct links.
- Return the ids in the target's component, leaving out the target, as an
int[]sorted in ascending order.
More Stripe Phone Screen questions
- Split Tender Part 4 - RefundsOA · PHONE SCREEN · Seen Nov 2026
- Merchant Payout Reserve CalculatorPHONE SCREEN · Seen Nov 2026
- Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
- Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsPHONE SCREEN · Seen Nov 2026
- Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
- Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
- Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesPHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Sentence Equivalence with SynonymsRead AI · PHONE SCREEN
- Find Duplicate Files in a FilesystemHarvey · PHONE SCREEN · ONSITE INTERVIEWHarvey interview questions
- Shortest Word Transformation SequenceReddit · PHONE SCREENReddit interview questions
- Word LadderGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
- Word Ladder IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Find Minimum City HopsAmazon · OA
- Shortest Path from Encoded Graph EdgesBitGo · OABitGo interview questions
- Count Distinct Word MeaningsDuolingo · OADuolingo interview questions
- Word LadderGoogle · ONSITE INTERVIEWGoogle interview questions
- Word LadderMicrosoft · ONSITE INTERVIEWMicrosoft interview questions