Mailroom Router

The Luma Mailroom routes every incoming address through a normalizer before sorting. Each address has a local part and a domain part separated by a single @. The domain is delivered exactly as written. The local part is canonicalized with two rules applied in order:

  1. Everything from the first + in the local part up to the @ is discarded. If there is no +, nothing is discarded.
  2. All . characters are removed from the remaining local part.

Two addresses reach the same mailbox when their normalized forms are identical. Given the full list emails, return how many distinct mailboxes are reached.

Apply the plus rule before the dot rule on the truncated local, and never modify the domain. A dot in the domain is not removed.

Examples
Input: ["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"]
Output: 2
Hints

Mailroom Router

The Luma Mailroom routes every incoming address through a normalizer before sorting. Each address has a local part and a domain part separated by a single `@`. The domain is delivered exactly as written. The local part is canonicalized with two rules applied in order: