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.

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

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
String Parsing
Normalization
Hash Set
Canonical Form
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
  • 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 Problems
Sample Answer
Requirements
  • Input: a list of strings, each meant to look like local@domain.
  • Output: the number of distinct inboxes.
  • For gmail.com and googlemail.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...


Submit Your Answer
Markdown supported