Description

Every email consists of a local name and a domain name, separated by the @ sign.

For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name.

Besides lowercase letters, these emails may contain '.'s or '+'s.

If you add periods ('.') between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. For example, "alice.z@leetcode.com" and "alicez@leetcode.com" forward to the same email address. (Note that this rule does not apply for domain names.)

If you add a plus ('+') in the local name, everything after the first plus sign will be ignored. This allows certain emails to be filtered, for example m.y+name@email.com will be forwarded to my@email.com. (Again, this rule does not apply for domain names.)

It is possible to use both of these rules at the same time.

Given a list of emails, we send one email to each address in the list. How many different addresses actually receive mails?

Example 1:

Input: ["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"]

Output: 2

Explanation: "testemail@leetcode.com" and "testemail@lee.tcode.com" actually receive mails

Note:

1 <= emails[i].length <= 100

1 <= emails.length <= 100

Each emails[i] contains exactly one '@' character.

My Submission

解题思路

遇到问题

Sample Submission

sample 8 ms submission

int numUniqueEmails(char** emails, int emailsSize) {
char map[100][100];
char temp[100]={0};
int count = 0;
int j = 0;
int k = 0;
int find = 0; // whether find '+'
for(int i = 0; i < emailsSize; i++){
j = 0;
find = 0;
k = 0;
while(emails[i][j] != '@'){
if(find){
j++;
continue;
} if(emails[i][j] == '.'){
j++;
}
else if(emails[i][j] == '+' ){
find = 1;
j++;
}
else{
temp[k] = emails[i][j];
j++;
k++;
}
} while(emails[i][j]){
temp[k] = emails[i][j];
k++;
j++;
}
temp[k] = 0; find = 0;
for(int m = 0; m < count; m++){
if(strcmp(temp,map[m]) == 0){
find = 1;
break;
}
} if(!find){
strcpy(map[count],temp);
count++;
}
} return count;
}

LeetCode 929.Unique Email Addresses的更多相关文章

  1. [leetcode] 929. Unique Email Addresses (easy)

    统计有几种邮箱地址. 邮箱名类型:local@domain 规则:1. local中出现"."的,忽略. a.bc=abc 2. local中出现"+"的,+以 ...

  2. [LeetCode] 929. Unique Email Addresses 唯一的电邮地址

    Every email consists of a local name and a domain name, separated by the @ sign. For example, in ali ...

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

    Every email consists of a local name and a domain name, separated by the @ sign. For example, in ali ...

  4. LeetCode 929 Unique Email Addresses 解题报告

    题目要求 Every email consists of a local name and a domain name, separated by the @ sign. For example, i ...

  5. LeetCode 929. Unique Email Addresses (独特的电子邮件地址)

    题目标签:String 题目说明 有两个规则针对于 local name. 所以先把local name 和 domain name 分开. 两个规则是: rule 1:'.' 会被去除. (利用re ...

  6. 929. Unique Email Addresses

    929. Unique Email Addresses Easy 22766FavoriteShare Every email consists of a local name and a domai ...

  7. 【Leetcode_easy】929. Unique Email Addresses

    problem 929. Unique Email Addresses solution: class Solution { public: int numUniqueEmails(vector< ...

  8. 【leetcode】929. Unique Email Addresses

    题目如下: Every email consists of a local name and a domain name, separated by the @ sign. For example, ...

  9. 【LeetCode】929. Unique Email Addresses 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 set + 字符串操作 参考资料 日期 题目地址:h ...

随机推荐

  1. [powershell] 批量重命名,修改文件名中的部分字符串

    实例:替换一个目录下所有的字幕文件从720p到1080p ls $Path -Recurse |ForEach-Object{Rename-Item $_.FullName $_.FullName.R ...

  2. 深入理解JVM(2)——运行时数据区

    1.运行时数据区 1.1.程序计数器 记录当前线程正在执行的字节码指令的地址,如果正在执行的是 Native 方法,这个计数器值则为空. 1.2.虚拟机栈 每个 Java 方法在执行的同时会创建一个栈 ...

  3. zabbix存储history_text

    有一个监控项存储一个目录的所有文件(递归)信息,字符数量比较大,history_str表的value的字段字符数限制为255长度,所以就想存储到history_text表中,在最新数据中一直显示不出新 ...

  4. 一种特殊的 jpg 图片: MagickProfileImage() sRGB.icc

    原图,在 ps, 浏览器中显示这样: 在 ps 中另存为 web... [转换成 sRGB]选项没有勾选: 在 ps 中另存为 web... 勾选[转换成 sRGB]选项: 用 ImageMaigck ...

  5. The Preliminary Contest for ICPC China Nanchang National Invitational and International Silk-Road Programming Contest

    打网络赛 比赛前的准备工作要做好 确保 c++/java/python的编译器能用 打好模板,放在桌面 A. PERFECT NUMBER PROBLEM #include <cstdio> ...

  6. 金融量化分析【day111】:Matplotib-画布与子图

    一.画布与子图 1.实例 %matplotlib auto fig = plt.figure() ax = fig.add_subplot(2,2,1) ax2 = fig.add_subplot(2 ...

  7. [再寄小读者之数学篇](2014-06-20 求极限-L'Hospital 法则的应用)

    设 $f\in C[0,+\infty)$, $a$ 为实数, 且存在有限极限 $$\bex \vlm{x}\sez{f(x)+a\int_0^x f(t)\rd t}. \eex$$ 证明; $f( ...

  8. PHP数组——数组正则表达式、数组、预定义数组

    正则表达式 1.替换 $s = "hello5world"; $s = preg_replace("/\d/","#",$s); echo ...

  9. Pycharm工具导入requests包(python新手)

    在学习使用python的过程中选择了工具Pycharm,但是如下代码: ,起初导包一直报错,解决办法:File->Setting 点击右上角+号,打开搜素对话框 搜素需要的导包,并加入即可解决此 ...

  10. java PDF2JPG

    import org.apache.commons.lang3.StringUtils; import org.apache.pdfbox.pdmodel.PDDocument; import org ...