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. 深入理解JVM(4)——对象的创建和访问

    1.对象的创建 在语言层面上,创建对象(例如克隆,反序列化)通常仅仅是一个new关键字而已. 在虚拟机中,对象(文中讨论的对象限于普通 Java 对象,不包括数组和 Class 对象等)的创建过程如下 ...

  2. CF765F Souvenirs

    CF765F Souvenirs [CF765F]Souvenirs 主席树 - CQzhangyu - 博客园 其实不用主席树 感觉像是离线问题 但是不能支持差分.分治又处理不了 考虑按照右端点排序 ...

  3. 3173. 【GDOI2103模拟3.17】扫雷游戏(搜索 + 剪枝)

    Problem 给出一个类似扫雷的游戏,有\(num\)个数字,求至少有多少个雷. Data constraint \(n,m\le 15,num\le 15\) Solution 好搜索啊. 现讲一 ...

  4. Spark Java API 之 CountVectorizer

    Spark Java API 之 CountVectorizer 由于在Spark中文本处理与分析的一些机器学习算法的输入并不是文本数据,而是数值型向量.因此,需要进行转换.而将文本数据转换成数值型的 ...

  5. 微信小程序 mpvue vant

    Mpvue中使用Vant Weapp组件库 https://segmentfault.com/a/1190000016228410?utm_source=tag-newest 小程序采坑记 mpvue ...

  6. [物理学与PDEs]第2章习题2 质量力有势时的能量方程

    试证明: 如果质量力有势, 即存在 $\phi$ 使 ${\bf F}=-\n \phi$, 那么理想流体的能量守恒方程的微分形式可写为 $$\bex \cfrac{\rd}{\rd t}\sex{e ...

  7. How far away ? HDU - 2586 【LCA】【RMQ】【java】

    题目大意:求树上任意两点距离. 思路: dis[i]表示i到根的距离(手动选根),则u.v的距离=dis[u]+dis[v]-2*dis[lca(u,v)]. lca:u~v的dfs序列区间里,深度最 ...

  8. ps常用指令集

    M DCtrl+ D清空选择区域Ctrl+ R调出标尺

  9. django drf 开发 ~ models基础学习

    零 介绍  对于ORM框架,可以简单的认为自定义类U表示数据库的表:根据类创建的对象表示数据库表一 数据表设计  1 类型统计     CharField->(string)->(1 ma ...

  10. Script error.解决方法

    1. 添加 crossorigin="anonymous" 到script标签 <script src="https://xxx.com/xxx.js" ...