Merge Duplicate CRM Contacts by Normalized Email Address

Last updated: November 29, 2026

Quick Overview

Given a list of contact records with an email, an updated_at timestamp and arbitrary property fields, merge records that share the same normalized email into one record, keeping the newest non-empty value for each property. Records without a usable email should pass through unchanged.

HubSpot
Coding & Algorithms
Software Engineer
HubSpot
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a list of contact records with an email, an updated_at timestamp and arbitrary property fields, merge records that share the same normalized email into one record, keeping the newest non-empty value for each property. Records without a usable email should pass through unchanged.

Duplicate contacts are one of the most common data quality complaints in any CRM, and HubSpot ships dedup and merge tooling for exactly this. A phone screen version checks that you clarify normalization rules before coding and produce clean, deterministic merge logic.

What the Interviewer Expects
  • Asks what counts as the same email (case, whitespace, plus tags, Gmail dots) before coding
  • Groups records in one pass with a hash map keyed by the normalized email
  • Defines a clear conflict rule: newest non-empty value wins per property
  • Keeps a stable primary id and records which ids were merged
  • Handles missing or malformed emails without crashing
Key Topics to Cover
hashing
string normalization
record merging
data quality
determinism
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
  • How would you merge when two contacts share a phone number but have different emails?
  • How would you make the merge reversible if a user says it was wrong?
  • How does this change when there are 50 million contacts in one portal?
  • Should some properties (like lifecycle stage) use a different rule than newest wins?
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: a list of dicts, each with id, email, updated_at and other properties. Output: one record per normalized email. I would confirm the normalization rules: lowercase and trim, drop a +tag ...

High-Level Design
  1. Normalize each email; records with no @ are passed through.
  2. Bucket records into a dict keyed by normalized email, remembering first-seen order so output is deterministic.
  3. For each bucket, s...

Submit Your Answer
Markdown supported

Related Questions