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
November 29, 20260
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
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
- 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 ProblemsSample 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 ...