Unique Email Addresses
Every valid email consists of a local name and a domain name, separated by the '@' symbol. Emails also may contain dots or plus signs. A dot in the local name of the email is ignored. Everything after a plus sign in the local name is ignored, as well as the plus sign itself. For instance, the email 'example.email+tag@gmail.com' is treated as 'exampleemail@gmail.com'. Given a list of n emails, return the total number of unique addresses that actually receive mails.
[ "test.email+alex@leetcode.com", "test.e.mail+bob.cathy@leetcode.com", "testemail+david@lee.tcode.com" ]
Explanation. The first and second emails normalize to 'testemail@leetcode.com' and thus are counted as one unique email. The third email is different; hence there are two unique emails.
[ "a@leetcode.com", "b@leetcode.com" ]
Explanation. Both emails are unique as they are.
[ "dot.email+ignore@leetcode.com", "dotemail@leetcode.com" ]
Explanation. Both normalize to 'dotemail@leetcode.com'.
[ "nodots@leetcode.com", "n.o.d.o.t.s@leetcode.com" ]
Explanation. Dots are ignored in the local name, hence both are treated as 'nodots@leetcode.com'.
Follow-up: How would you handle cases where domain names could contain special normalization rules?
1. Each email will contain exactly one '@' symbol.\n2. The local and domain parts of the email addresses will only consist of lowercase letters, digits, plus signs, and/or dots.\n3. The input list will contain at least one and no more than 100 emails.
- Views
- 2