Merge Duplicate Customer Records That Share an Email or Phone

Last updated: November 29, 2026

Quick Overview

A small business imports customers from several sources into QuickBooks, creating duplicates. Given records that each carry a list of emails and phone numbers, group together all records connected directly or transitively by a shared identifier.

Intuit
Coding & Algorithms
Software Engineer
Intuit
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


A small business imports customers from several sources into QuickBooks, creating duplicates. Given records that each carry a list of emails and phone numbers, group together all records connected directly or transitively by a shared identifier.

QuickBooks and Mailchimp both deal with messy contact data, and merging duplicates is a common onsite problem at Intuit because it rewards seeing the connected-components structure. The interviewer wants union find (or BFS on a graph), sensible normalization of phone numbers and emails, and awareness that transitive merges can over-merge.

What the Interviewer Expects
  • Recognize that duplicates form connected components, including transitive links
  • Implement union find with path compression and union by rank, or an equivalent BFS
  • Map each identifier to the first record that used it to avoid building all pairs
  • Normalize identifiers before comparing
  • Discuss the risk of over-merging on shared identifiers like a front-desk phone
Key Topics to Cover
union find
connected components
normalization
entity resolution
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • A shared office phone links 500 unrelated customers. How do you prevent that giant merge?
  • How would you undo a merge the user says was wrong?
  • How would you choose which record's name and address survive the merge?
  • How does this change when records stream in continuously?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: [(record_id, [identifiers])]. Two records belong together if they share any identifier, and the relation is transitive. Output: groups of record ids. Identifiers should be normalized first: l...

High-Level Design

Union find over record indices. Keep a dict identifier -> first record index that used it. For each identifier on a record, if someone already owns it, union the two records, otherwise claim it. Tha...


Submit Your Answer
Markdown supported

Related Questions