1、题目描述

2、问题分析

将字符串中的 ‘.’ 去掉,将 ‘+’后面直到‘@’的字符串去掉,然后利用set的特性。

3、代码

 int numUniqueEmails(vector<string>& emails) {
if (emails.size() == || emails.size() == )
return emails.size(); set<string> se; for (vector<string>::iterator it = emails.begin(); it != emails.end(); it++) {
string s = *it;
auto itr = s.begin();
auto itp = s.begin();
bool isplus = false;
while (*itr != '@') {
if (*itr == '.') {
s.erase(itr-s.begin(),);
} if (*itr == '+') {
itp = itr;
while (*itr != '@')
itr++;
s.erase(itp, itr);
break;
}
itr++;
} se.insert(s);
} return se.size();
}

LeetCode题解之Unique Email Addresses的更多相关文章

  1. 108th LeetCode Weekly Contest Unique Email Addresses

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

  2. 【leetcode】929. Unique Email Addresses

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

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

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

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

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

  5. 929. Unique Email Addresses

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

  6. 【Leetcode_easy】929. Unique Email Addresses

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

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

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

  8. LeetCode 929.Unique Email Addresses

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

  9. LeetCode - Unique Email Addresses

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

随机推荐

  1. C#基础篇八构造函数和面向对象思想

    3.关于 对象创建的几个关键词 Dog d1 = new Dog(); Dog d1 叫做 声明变量 new Dog() 叫做 实例化(创建)对象 4.关于对象.方法和 this 的关系 Dog d1 ...

  2. DataSet 多表关系

    protected void Page_Load(object sender, EventArgs e) { string connectionString = @"Data Source= ...

  3. 软件架构设计学习总结(15):远程通信(RPC,Webservice,RMI,JMS、EJB、JNDI的区别)对比

    总结这些概念都是易混淆,最基本概念定义复习和深入理解,同时也是架构师必备课程   RPC(Remote Procedure Call Protocol) RPC使用C/S方式,采用http协议,发送请 ...

  4. SSH-公私钥认证

    Linux下SSH的认证方式有两种,即密码认证和公私钥认证. 我们在日常的安全维护中,出于安全的考虑,密码不明文存放,会使用公私钥认证方式.这个时候我们就需要使用ssh-keygen,ssh-keyg ...

  5. VGG 论文研读

    VERY DEEP CONVOLUTIONAL NETWORKS FOR LARGE-SCALE IMAGE RECOGNITION 论文地址 摘要 研究主要贡献是通过非常小的3x3卷积核的神经网络架 ...

  6. android开发学习笔记系列(5)--fragment与viewpage

    前言 在前面的博客写到我针对一个项目完成了动态布局的效果,顿时感觉很爽,那么下面我针对我在前文中所讲的tabhost的实现做出一个新的方法,tabhost基本已经被启用,现在基本使用Fragment与 ...

  7. Core Animation之CABasicAnimation(基础动画)

    #import "ViewController.h" @interface ViewController () @property(nonatomic,strong)UIButto ...

  8. 任意的组合,数组或数组,数组或list,list或list不用循环得出匹配的总数和需要的字段列

    var res = list.Where(p=> list2.Any(x=>x.Id == p.Id));var count = res.Count();var ids = res.Sel ...

  9. $.ajax()参数详解及标准写法(转)

    1.url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. 2.type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如 ...

  10. winform 窗体中 Time 控件的用法

    作用: 用于背景进程中.通过引发Timer事件,Timer控件可以有规律的隔一段时间执行一次代码.也就是,你可以根据你自己的需要,给Timer控件设置时间,Timer每隔这段时间,就执行一次代码. 属 ...