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. Python【第二篇】运算符及优先级、数据类型及常用操作、深浅拷贝

    一.运算符及优先级 Python 运算符(算术运算.比较运算.赋值运算.逻辑运算.成员运算) 1.算数运算符 运算符 描述 实例,a=20,b=10 + 加 a+b输出结果30 - 减 a-b输出结果 ...

  2. tex 进度条

    \documentclass{beamer} \usepackage{tikz} \usetikzlibrary{calc} \definecolor{pbblue}{HTML}{0A75A8}% f ...

  3. [物理学与PDEs]第2章第5节 一维流体力学方程组的 Lagrange 形式 5.2 Lagrange 坐标

    1. Lagrange 坐标 $$\beex \bea &\quad 0=\int_\Omega\cfrac{\p \rho}{\p t}+\cfrac{\p}{\p x}(\rho u)\r ...

  4. DevExpress 控件汉化方法

    Ø  简介 本文介绍下 DevExpress 控件的汉化方法,对于英文不怎么好的同学来说,还是非常有必要的.DevExpress 汉化分为运行时汉化,和设计时汉化. 1.   运行时汉化 1)   首 ...

  5. String总结

  6. phpstudy 安装Apache SSL证书实现https连接

    Windows phpstudy安装ssl证书教程. 工具/原料   phpstudy 集成环境 申请的SSL证书 方法/步骤     首先申请免费的ssl证书,很多地方都可以申请.我是在腾讯云!如图 ...

  7. python 中and,or计算规则

    and :如果表达式都不为假,则返回最后一个表达式的值,如果为假返回第一个表达式为假的值.(遇到假的表达式就返回此表达式的值) or :如果都为假,,返回最后一个假表达式的值,如果有真,则返回第一个真 ...

  8. Web从入门到放弃<8>

    Ref: Cameron D. - HTML5, JavaScript and jQuery (Programmer to Programmer) - 2015 http://www.runoob.c ...

  9. Idea 问题记录

    日常问题记录 下载IDEA, tomcat ,下载jdk 前言:java net对比 Java:JDK  .NET:.NetFramework WEB服务器 Java:Tomcat,JBoss,Web ...

  10. 题解-CodeChef IOPC14L Sweets Problem

    Problem CodeChef-IOPC14L 题目概要:给定 \(n\) 种糖果且给定每种糖果的数量 \(A_i\),\(Q\) 组询问,每次问选出 \(S\) 个糖果的方案数(模\(10^9+7 ...