#929

Unique Email Addresses

pupil · 315 · lc easy +21 · verified · 67.8% accepted · 2,806 likes · top 74%

Description

Email normalization applies two rules to the local part (before '@'): dots '.' are ignored, and everything from the first '+' onward (before '@') is discarded. Given an array of email strings emails, return the count of distinct normalized addresses actually receiving mail.

Example 1:

Input: emails = ["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"]
Output: 2
Explanation: "testemail@leetcode.com" and "testemail@lee.tcode.com" actually receive mails.

Example 2:

Input: emails = ["a@leetcode.com","b@leetcode.com","c@leetcode.com"]
Output: 3

Code

1
2
3