Unique Email Addresses
Every email consists of a local name and a domain name, separated by the '@' character. For example, in alice@coding.com, alice is the local name, and coding.com is the domain name. An email may also contain '+' or '.' characters in the local name. A '.' in the local name is ignored, and everything after a '+' in the local name is also ignored when determining the uniqueness of an email address. Given a list of email addresses, return the number of unique email addresses that actually receive mails.
[ [ "test.email+alex@leetcode.com", "test.e.mail+bob.cathy@leetcode.com", "testemail+david@lee.tcode.com" ] ]
Explanation. The unique emails are 'testemail@leetcode.com' and 'testemail@lee.tcode.com'. Even though they appear under different variations, after processing them according to the rules, these are the two unique addresses that receive emails.
[ [ "a@leetcode.com", "b@leetcode.com" ] ]
Explanation. Both emails are unique as specified, thus they count separately.
[ [ "alphabet+one@ex.com", "al.ph.abe.ton.e@ex.com", "alphabet+two@ex.com" ] ]
Explanation. There are two unique email addresses: 'alphabet@ex.com' (from the first two inputs) and 'alphabettwo@ex.com' (from the third input).
Follow-up: Could you use a hashing technique to solve this problem efficiently?
1. Each email address contains exactly one '@' character.\n2. The local part and the domain part of the email address will only contain lowercase letters, '.' or '+'.\n3. The list of email addresses will have at least one element.
- Views
- 3