929. Unique Email Addresses
22766FavoriteShare
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 <= 1001 <= emails.length <= 100- Each 
emails[i]contains exactly one'@'character. 
class Solution {
public:
         int numUniqueEmails(vector<string>& emails) {
            map<string,int> m1;
            int point,add,at;
            for(auto &astr:emails){
                at=findc(astr,'@',,astr.length()-);
                if(at!=-){
                    while( (add=findc(astr,'+',,at)) !=-){
                        astr.erase(add,at-add);
                        at-=(at-add);
                    }
                }
                while( (point=findc(astr,'.',,at)) != -){
                    astr.erase(point,);
                    at-=;
                }
                m1[astr]++;
            }
            return m1.size();
        }
        int findc(string str,char c,int start,int end){
            for(int i=start;i<=end;i++){
                if(str[i]==c) return i;
            }
            return -;
        }
};
929. Unique Email Addresses的更多相关文章
- 【Leetcode_easy】929. Unique Email Addresses
		
problem 929. Unique Email Addresses solution: class Solution { public: int numUniqueEmails(vector< ...
 - [leetcode] 929. Unique Email Addresses (easy)
		
统计有几种邮箱地址. 邮箱名类型:local@domain 规则:1. local中出现"."的,忽略. a.bc=abc 2. local中出现"+"的,+以 ...
 - [LeetCode] 929. Unique Email Addresses 唯一的电邮地址
		
Every email consists of a local name and a domain name, separated by the @ sign. For example, in ali ...
 - [LeetCode] 929. Unique Email Addresses 独特的邮件地址
		
Every email consists of a local name and a domain name, separated by the @ sign. For example, in ali ...
 - LeetCode 929.Unique Email Addresses
		
Description Every email consists of a local name and a domain name, separated by the @ sign. For exa ...
 - LeetCode 929 Unique Email Addresses 解题报告
		
题目要求 Every email consists of a local name and a domain name, separated by the @ sign. For example, i ...
 - 【leetcode】929. Unique Email Addresses
		
题目如下: Every email consists of a local name and a domain name, separated by the @ sign. For example, ...
 - 【LeetCode】929. Unique Email Addresses 解题报告(Python)
		
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 set + 字符串操作 参考资料 日期 题目地址:h ...
 - LeetCode 929. Unique Email Addresses (独特的电子邮件地址)
		
题目标签:String 题目说明 有两个规则针对于 local name. 所以先把local name 和 domain name 分开. 两个规则是: rule 1:'.' 会被去除. (利用re ...
 
随机推荐
- Leetcode-1.两数之和
			
题目描述: 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标. 你可以假设每种输入只会对应一个答案.但是,你不能重复利用这个数 ...
 - [Kubernetes]浅谈容器网络
			
Veth Pair 这部分内容主要介绍一个设备: Veth Pair . 作为一个容器,它可以声明直接使用宿主机的网络栈,即:不开启 Network Namespace .在这种情况下,这个容器启动后 ...
 - Git管理源代码
			
Git Git 是目前世界上最先进的分布式版本控制系统(没有之一) 作用 源代码管理 为什么要进行源代码管理? 方便多人协同开发 方便版本控制 Git单人本地仓库操作 安装git sudo apt-g ...
 - Linux启动activemq失败
			
第一种情况: 在网上查找错误,通过./activemq console命令可以查看到activemq启动的错误信息,另外在data/activemq.log文件中可以查看到错误日志. java.io. ...
 - 【转】Python函数默认参数陷阱
			
[转]Python函数默认参数陷阱 阅读目录 可变对象与不可变对象 函数默认参数陷阱 默认参数原理 避免 修饰器方法 扩展 参考 请看如下一段程序: def extend_list(v, li=[]) ...
 - C++头文件用<>还是“” 以及 要加.h还是不加 的问题
			
1.C++头文件用<>包含还是” “? 答:用<>包含,编译器会先在系统目录下搜索: 用” ” 包含,编译器会先在用户目录下搜索. 所以,如果使用系统标准库,要使用<&g ...
 - OpenStack—nova组件计算服务
			
nova介绍: Nova 是 OpenStack 最核心的服务,负责维护和管理云环境的计算资源.OpenStack 作为 IaaS 的云操作系统,虚拟机生命周期管理也就是通过 Nova 来实现的. 用 ...
 - php 常用的知识点归集(上)
			
1.php if...else 在html中的替代语法 <?php $name = 'ok' ?> <?php if ($name == '1ok') : ?> <div ...
 - 生成免费SSL通配证书
			
通过Let's Encrypt 生成免费SSL证书 有效期是3个月 1.下载工具certbot-auto wget https://dl.eff.org/certbot-auto chmod +x c ...
 - TP-Shop安装步骤教程(Windows版)
			
TP-Shop安装步骤教程(Windows版) PS:首次发文,请多指教! 一.安装要求 1.PHP5.4以上,MYsql5.5以上. 2.需要Phpcurl,gd库.php_mysqli,php_o ...