Leetcode-929 Unique Email Addresses(独特的电子邮件地址)

 1 class Solution
 2 {
 3     public:
 4         int numUniqueEmails(vector<string>& emails)
 5         {
 6             for(int i = 0;i < emails.size();i ++)
 7             {
 8                 for(int j = 0;j < emails[i].size();j ++)
 9                 {
10                     if(emails[i][j]==‘@‘)
11                     {
12                         for(int k = 0;k < j;k ++)
13                         {
14                             if(emails[i][k]==‘.‘)
15                             {
16                                 emails[i].erase(k,1);
17                                 k --;
18                                 j --;
19                             //    cout << k << endl;
20                             }
21                             else if(emails[i][k]==‘+‘)
22                             {
23                                 emails[i].erase(k,j-k);
24                                 break;
25                             }
26                         }
27                     }
28                 }
29             }
30
31             set<string> strSet;
32             for(auto s:emails)
33                 strSet.insert(s);
34             return strSet.size();
35         }
36 };

原文地址:https://www.cnblogs.com/Asurudo/p/9878728.html

时间: 2024-11-14 15:38:17

Leetcode-929 Unique Email Addresses(独特的电子邮件地址)的相关文章

[LeetCode] 929. Unique Email Addresses 独特的邮件地址

Every email consists of a local name and a domain name, separated by the @ sign. For example, in?[email protected],?alice?is the local name, and?leetcode.com?is the domain name. Besides lowercase letters, these emails may contain?'.'s or?'+'s. If you

[leetcode] 929. Unique Email Addresses (easy)

统计有几种邮箱地址. 邮箱名类型:[email protected] 规则:1. local中出现"."的,忽略. a.bc=abc 2. local中出现"+"的,+以及之后的local全部忽略. a+bc=a 思路: 利用set存,水题没啥好说的 Runtime: 20 ms, faster than 96.66% of C++ online submissions for Unique Email Addresses. class Solution { pub

LeetCode 929 Unique Email Addresses 解题报告

题目要求 Every email consists of a local name and a domain name, separated by the @ sign. For example, in [email protected], alice is the local name, and leetcode.com is the domain name. If you add periods ('.') between some characters in the local name 

929. Unique Email Addresses

Algorithm 做一个 leetcode 的算法题 Unique Email Addresses https://leetcode.com/problems/unique-email-addresses/ 1)problem 929. Unique Email Addresses Every email consists of a local name and a domain name, separated by the @ sign. For example, in [email pro

【leetcode】929. Unique Email Addresses

题目如下: Every email consists of a local name and a domain name, separated by the @ sign. For example, in [email protected], alice is the local name, and leetcode.com is the domain name. Besides lowercase letters, these emails may contain '.'s or '+'s.

验证-- email类型输入框(电子邮件地址)--multiple

如果需要一个用来填写电子邮件地址的输入框,可以使用email类型.这样浏览器可以帮我们验证格式是否正确,而不需要自己写验证规则.原文:HTML5新控件 - email类型输入框(电子邮件地址) 1,只允许输入单个邮件地址1<input type="email"/> 2,允许输入多个邮件地址(用逗号分隔)1<input type="email" multiple/>

[Swift Weekly Contest 108]LeetCode929. 独特的电子邮件地址 | Unique Email Addresses

Every email consists of a local name and a domain name, separated by the @ sign. For example, in [email protected], alice is the local name, and leetcode.com is the domain name. Besides lowercase letters, these emails may contain '.'s or '+'s. If you

【leecode】独特的电子邮件地址

每封电子邮件都由一个本地名称和一个域名组成,以 @ 符号分隔. 例如,在 [email protected]中, alice 是本地名称,而 leetcode.com 是域名. 除了小写字母,这些电子邮件还可能包含 ',' 或 '+'. 如果在电子邮件地址的本地名称部分中的某些字符之间添加句点('.'),则发往那里的邮件将会转发到本地名称中没有点的同一地址.例如,"[email protected]" 和 "[email protected]" 会转发到同一电子邮件

力扣——独特的电子邮件地址

每封电子邮件都由一个本地名称和一个域名组成,以 @ 符号分隔. 例如,在 [email protected]中, alice 是本地名称,而 leetcode.com 是域名. 除了小写字母,这些电子邮件还可能包含 ',' 或 '+'. 如果在电子邮件地址的本地名称部分中的某些字符之间添加句点('.'),则发往那里的邮件将会转发到本地名称中没有点的同一地址.例如,"[email protected]" 和 "[email protected]" 会转发到同一电子邮件