Merge Records From Many Sources Into Resolved Entities
Last updated: November 29, 2026
Quick Overview
You receive person records from several source systems, each with an id and optional identifier fields such as email, phone, or passport number. Two records describe the same entity if they share any normalized identifier value of the same type, and this relation is transitive; return the groups of record ids that form each resolved entity.
Palantir
November 29, 20260
0
0 solved
You receive person records from several source systems, each with an id and optional identifier fields such as email, phone, or passport number. Two records describe the same entity if they share any normalized identifier value of the same type, and this relation is transitive; return the groups of record ids that form each resolved entity.
Fusing messy records from many systems into one object per real-world entity is the core of what Foundry's Ontology and Gotham's investigations depend on. This question checks whether the candidate recognizes a connected-components problem hiding inside a data-cleaning story and handles the dirty-data details (nulls, casing, whitespace) that real source systems produce.
What the Interviewer Expects
- Recognize transitive matching as connected components and choose union-find or graph BFS
- Avoid the O(n^2) pairwise comparison by indexing on (field, value) tokens
- Normalize values and skip null or empty identifiers so blanks do not merge everything
- Keep identifier types separate so a phone value never matches an email value
- Return deterministic output (sorted groups) and state complexity clearly
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Records now arrive as a stream; how do you update groups incrementally, and what happens when a merge must be undone?
- A shared office phone number links hundreds of unrelated people. How do you stop one weak identifier from collapsing many entities?
- How would you run this across billions of records in a Spark pipeline?
- How would you explain to an analyst why two records were merged?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: a list of records like {"id": "r1", "email": "[email protected]", "phone": None} and the list of identifier fields to match on. Two records match if they share a value for the same field after trimming...
High-Level Design
Comparing every pair is O(n^2 * k). Instead, treat each (field, normalized_value) as a token. Keep a map from token to the first record that owned it. When a later record carries the same token, uni...