# 929.Unique Email Address

**929.Unique Email Addresses**

难度:Easy

> 每封电子邮件都由一个本地名称和一个域名组成，以 @ 符号分隔。 例如，在 <alice@leetcode.com>中， alice 是本地名称，而 leetcode.com 是域名。 除了小写字母，这些电子邮件还可能包含 '.' 或 '+'。 如果在电子邮件地址的本地名称部分中的某些字符之间添加句点（'.'），则发往那里的邮件将会转发到本地名称中没有点的同一地址。例如，"<alice.z@leetcode.com>” 和 “<alicez@leetcode.com>” 会转发到同一电子邮件地址。 （请注意，此规则不适用于域名。） 如果在本地名称中添加加号（'+'），则会忽略第一个加号后面的所有内容。这允许过滤某些电子邮件，例如 <m.y+name@email.com> 将转发到 <my@email.com>。 （同样，此规则不适用于域名。） 可以同时使用这两个规则。 给定电子邮件列表 emails，我们会向列表中的每个地址发送一封电子邮件。实际收到邮件的不同地址有多少？

```
示例：

输入：["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"]
输出：2
解释：实际收到邮件的是 "testemail@leetcode.com" 和 "testemail@lee.tcode.com"。
 

提示：

1 <= emails[i].length <= 100
1 <= emails.length <= 100
每封 emails[i] 都包含有且仅有一个 '@' 字符。
```

代码如下：

```
class Solution {
public:
    int numUniqueEmails(vector<string>& emails) {
        unordered_set<string> uni_email;
        for(auto email: emails)
        {
            int flag=1;
            string tmp;
            for(auto c: email)
            {
                
                if(c=='.' && flag==1) continue;
                if(c=='@') flag=2;
                if(c=='+' && flag==1) flag=0;
                if(flag) tmp+=c;
            }
            uni_email.insert(tmp);
        }
        return uni_email.size();
    }
};
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dfine.gitbook.io/leetcode/929.unique_email_address.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
