> ## Content Index
> Fetch the complete content index at: https://andybase.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# 929. Unique Email Addresses
- URL: https://andybase.com/unique-email-addresses/
- Published: 2018-10-29T19:18:09.000Z
- Updated: 2018-10-29T19:18:09.000Z
- Author: andy
- Tags: leetcode, contest, #Migrated-1784083136856, #wp, #wp-post, #Import 2026-07-15 02:38

Link: [Unique Email Addresses](https://leetcode.com/problems/unique-email-addresses/?ref=andybase.com)

## Thought

**Brutal Force Solution**  
This question is pretty simple (and it actually is an esay one). A naive approache is, split the name and domain.

For the name, **remove every thing after first '+'**, and then replace all '.' as empty. For the domain, just keep it is.

Then, use a set to make sure every thing is unique. After processed all emails, count the length of the set.

## Code

```
class Solution:
    def numUniqueEmails(self, emails):
        """
        :type emails: List[str]
        :rtype: int
        """
        hist = set()
        cnt = 0
        for email in emails:
            name, domain = email.split('@')
            name = name.split('+')[0]
            name=name.replace('.', '')
            if name + '@' + domain not in hist:
                hist.add(name+'@'+domain)
                cnt += 1
        return cnt
```

## Runtime

Time: O(n)  
Space: O(n)