[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)
                

  

posted @ 2020-02-06 14:57  阿牧遥  阅读(98)  评论(0编辑  收藏  举报