Count Distinct Gmail Inboxes After Normalizing Dots and Plus Tags
Last updated: November 29, 2026
Quick Overview
Given a list of email addresses, count how many distinct inboxes actually receive mail, knowing that for gmail.com (and its alias googlemail.com) dots in the local part are ignored, everything after a plus sign is ignored, and matching is case-insensitive.
0
0
0 solved
Given a list of email addresses, count how many distinct inboxes actually receive mail, knowing that for gmail.com (and its alias googlemail.com) dots in the local part are ignored, everything after a plus sign is ignored, and matching is case-insensitive.
A Google screen question tied to sign-up abuse and newsletter deduplication: many "different" addresses deliver to the same Gmail inbox. The interviewer checks careful string splitting, applying rules only to the right domain, and not over-normalizing other providers.
What the Interviewer Expects
- Splits each address into local part and domain exactly once on the @
- Applies dot and plus rules only to Gmail domains
- Lowercases before comparing and maps googlemail.com to gmail.com
- Uses a set of canonical forms to count distinct inboxes
- Mentions how malformed addresses are handled
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
- Return the groups of raw addresses per inbox instead of just the count.
- Other providers have their own rules; how would you make the normalizer configurable per domain?
- How would you run this deduplication over billions of sign-ups with MapReduce?
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 strings, each meant to look like
local@domain. - Output: the number of distinct inboxes.
- For
gmail.comandgooglemail.com: ignore case, drop every.in the local part, and...
High-Level Design
Map every address to a canonical key and count distinct keys with a set. The canonicalization is a small pipeline: trim and lowercase, split on @, fold the alias domain, and for Gmail strip the plus...