其他分享
首页 > 其他分享> > [leetcode]Unique Email Addresses

[leetcode]Unique Email Addresses

作者:互联网

简单题

class Solution:
    def numUniqueEmails(self, emails: List[str]) -> int:
        result = set()
        for email in emails:
            splits = email.split('@')
            name = splits[0] # to remove '.' & contents after '+'
            domain = splits[1]

            normName = ''
            for char in name:
                if char == '+':
                    break
                elif char == '.':
                    continue
                else:
                    normName += char

            result.add(normName + '@' + domain)

        return len(result)
                

  

标签:domain,Addresses,normName,email,char,result,Unique,leetcode,splits
来源: https://www.cnblogs.com/lautsie/p/12268740.html