题目链接:929. 独特的电子邮件地址
将邮件地址规约到最简格式,然后计算。
from typing import List
class Solution:
def numUniqueEmails(self, emails: List[str]) -> int:
def clean(email: str) -> str:
at = email.find('@')
host = email[:at]
if '+' in host:
host = host[:host.find('+')]
return host.replace('.', '') + email[at:]
return len(set(clean(e) for e in emails))