Group Duplicate Leads by Normalized Email Across Imports

Last updated: November 29, 2026

Quick Overview

Given a list of (lead_id, email) pairs from several CSV imports, normalize each email (trim, lowercase, drop plus tags, and ignore dots in Gmail local parts) and return every group of lead IDs that share a normalized address.

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

0

0

0 solved


Given a list of (lead_id, email) pairs from several CSV imports, normalize each email (trim, lowercase, drop plus tags, and ignore dots in Gmail local parts) and return every group of lead IDs that share a normalized address.

Salesforce phone screens often wrap a hashing warm-up in a CRM story, and duplicate management for Leads and Contacts is a core Sales Cloud feature. The interviewer checks that you clarify the normalization rules before coding and that you reach for a single-pass hash map instead of pairwise comparison.

What the Interviewer Expects
  • Ask which normalization rules apply and whether they are provider specific
  • Use a dictionary keyed by normalized email for one linear pass
  • Preserve input order of IDs within each group
  • Skip malformed emails rather than crashing
  • State O(n * L) time where L is email length
Key Topics to Cover
hash maps
string normalization
grouping
data quality
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 also match on phone number, so two leads are duplicates if either field matches?
  • The import has 50 million rows and does not fit in memory. What changes?
  • How would you make the normalization rules configurable per org, like Salesforce matching rules?
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: list of (lead_id, email). Output: list of groups (lists of IDs) with size at least 2. Normalization: trim whitespace, lowercase, remove everything after + in the local part, and for `gmail....

High-Level Design

Write a pure normalize(email) function so the rules are testable on their own, then bucket leads in a dict from normalized key to list of IDs. Return the buckets with more than one entry. Comparing ...


Submit Your Answer
Markdown supported

Related Questions