Unique Email Addresses
Given a list of email addresses, some of them could be simplified to the same address. For each email, separate it into local and domain parts where the local part is before the '@' and the domain part is after the '@'.\n\nRules for simplifying each email's local part are:\n1. Ignore everything after the first '+' (including the '+').\n2. Remove all periods ('.').\nThe domain part remains unchanged.\n\nWrite a function to count 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. There are two unique emails: 'testemail@leetcode.com' and 'testemail@lee.tcode.com'.
[ "a+alex@leetcode.com", "a.alex@leetcode.com" ]
Explanation. Both emails simplify to 'a@leetcode.com'.
[ "bob+123@domain.com", "bob@domain.com" ]
Explanation. Both simplify to 'bob@domain.com'.
Follow-up: Can you solve the problem in O(n) time complexity, where n is the total number of characters across all emails?
- The `emails` list will have at least 1 and no more than 100 elements.\n- Each email address contains exactly one '@' character.\n- The local and domain parts contain only lowercase letters, digits, '.', and '+', and neither parts will begin or end with a '.', or have two consecutive '.'s.
- Views
- 4