This continues the record-linkage problem. You are given user records and a weighted similarity rule, and must return the full set of records transitively connected to a target.
Inputs: rows (a String[] of "id,name,email,company"), weights (a String[] of "field,weight" over {name, email, company}, summing to 1), threshold, and targetId.
Two records are linked when their weighted field-equality similarity is >= threshold (each matching field contributes its weight). 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 if A and C are not directly linked.
Return the ids of every record in the same connected component as targetId (i.e. reachable through any chain of links), excluding the target itself, as an int[] sorted in ascending order.
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.5 targetId = 1 return = [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.5 targetId = 1 return = [2, 5]
- Each row is
"id,name,email,company"with an integer id. - Each weight entry is
"field,weight"over {name, email, company}; weights sum to 1. - Similarity = sum of weights of matching fields; records are linked when similarity
>= threshold. - Linkage is transitive (connected components over the similarity graph).
- Return the ascending-sorted
int[]of ids in the target's component, excluding the target.
- Account Balance Manager Part 3 - Platform CoverageONSITE INTERVIEW · Seen Jun 2026
- BitFont Part 3 - Decode Run-Length-Encoded RowsONSITE INTERVIEW · 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
- Account Balance Manager Part 2 - Reject OverdraftsONSITE INTERVIEW · Seen Jun 2026
- BitFont Part 2 - Render a WordONSITE INTERVIEW · Seen Jun 2026
- Factory Cost - Min-Cost Path Skipping One StagePHONE SCREEN · Seen Jun 2026
- HTTP Accept-Language with Quality Scores (q-factors)ONSITE INTERVIEW · Seen Jun 2026
public int[] findLinkedComponent(String[] rows, String[] weights, float threshold, int targetId) {
// write your code here
}