목차

Unique Email Addresses

ps
링크leetcode.com/…
출처LeetCode
문제 번호929
문제명Unique Email Addresses
레벨Easy
분류

기초

시간복잡도O(nm)
인풋사이즈n<=100, m<=100
사용한 언어Python
제출기록52ms / 14.3 MB
최고기록28ms
해결날짜2021/09/27

풀이

코드

"""Solution code for "LeetCode 929. Unique Email Addresses".

- Problem link: https://leetcode.com/problems/unique-email-addresses/
- Solution link: http://www.teferi.net/ps/problems/leetcode/929
"""

from typing import List


class Solution:
    def numUniqueEmails(self, emails: List[str]) -> int:
        emailSet = set()
        for email in emails:
            local, domain = email.split('@')
            forwardedLocal = local.split('+')[0].replace('.', '')
            emailSet.add((forwardedLocal, domain))
        return len(emailSet)