Leetcode 929. Unique Email Addresses
Posted 周洋的Blog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Leetcode 929. Unique Email Addresses相关的知识,希望对你有一定的参考价值。
简答题,字符串处理
class Solution(object): def numUniqueEmails(self, emails): """ :type emails: List[str] :rtype: int """ ans = [] for i, em in enumerate(emails): add, at = -1, -1 size = len(em) for j in range(size): if em[j] == ‘@‘: at = j break if em[j] == ‘+‘: if add == -1: add = j if add != -1: ans.append(em[:add].replace(‘.‘,‘‘) + em[at:]) else: ans.append(em[:at].replace(‘.‘,‘‘)+em[at:]) ans = set(ans) return len(ans)
以上是关于Leetcode 929. Unique Email Addresses的主要内容,如果未能解决你的问题,请参考以下文章
Leetcode 929. Unique Email Addresses
[LeetCode] 929. Unique Email Addresses 独特的邮件地址
LeetCode --- 929. Unique Email Addresses 解题报告