Unique Email Addresses
Every email address consists of a local name, an '@' symbol and a domain name, separated by the '@' sign. Write a function that accepts an array of email addresses and returns the number of unique addresses which actually send an email. Each email may be reformatted prior to being sent in the following ways:
- All dots in the local name are ignored.
- Everything after a plus sign (+) in the local name is ignored.
Example: For the email "john.doe+filter@exa.mple.com", the actual sending address would be "johndoe@exa.mple.com".
[ "test.email+alex@leetcode.com", "test.e.mail+bob.cathy@leetcode.com", "testemail+david@lee.tcode.com" ]
Explanation. The emails after formatting become: "testemail@leetcode.com", "testemail@leetcode.com", and "testemail@lee.tcode.com". The first two are the same, thus there are only 2 unique emails.
[ "a@leetcode.com", "b@leetcode.com" ]
Explanation. Both emails are unique.
[ "test.email+spam@leetcode.com", "test.email@leetcode.com" ]
Explanation. Ignore everything after '+' in the first email, both resolve to: "testemail@leetcode.com".
Follow-up: Can you derive a solution that processes the input emails in a single pass?
- An input array will not be null and will contain at least 1 email address. - Every string in the input array will be a valid email format with exactly one '@' symbol.