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. 客户端禁用cookie

    如果客户端禁用cookie的话不影响session使用 的设置方法: <sessionState     cookieless="AutoDetect"

  2. scala-传名函数和传值函数

    Scala的解释器在解析函数参数(function arguments)时有两种方式:先计算参数表达式的值(reduce the arguments),再应用到函数内部:或者是将未计算的参数表达式直接 ...

  3. maven-compiler-plugin 指定jdk的版本和编码

    为了让maven的jdk编译版本一致, 使用maven-compiler-plugin插件来协助管理 建议新建maven项目后的第一步就是配置该插件 <build> <plugins ...

  4. 核心组件之SecurityContextHolder

    作用:保留系统当前的安全上下文细节,其中就包括当前使用系统的用户的信息.   上下文细节怎么表示?     用SecurityContext对象来表示   每个用户都会有它的上下文,那这个Securi ...

  5. vue-cli watch/timer

    watch 监听函数 data:{ letter:'' }, watch:{ letter(){ xxxxxx } }, timer data(){ return{ timer:null } }, h ...

  6. SpringBoot 配置热部署

    做个记录,以免忘记: 1. 在 pom.xml 文件中的 dependencies 标签以内添加组件 devtools,具体内容如下: <!-- SpringBoot 热部署组件 devtool ...

  7. 在FireFox浏览器上,用stopImmediatePropagation阻止冒泡鼠标滚动事件

    楔子 是不是在火狐用stopPropagation不太满意 很久没有笑过又不知为何 既然不快乐又不喜欢这里 不如一路向西用stopImmediatePropagation(其实我对浏览器的兼容性看不顺 ...

  8. Netty 源码剖析之 unSafe.write 方法

    前言 在 Netty 源码剖析之 unSafe.read 方法 一文中,我们研究了 read 方法的实现,这是读取内容到容器,再看看 Netty 是如何将内容从容器输出 Channel 的吧. 1. ...

  9. .18-浅析webpack源码之compile流程-rules参数处理(1)

    Tips:写到这里,需要对当初的规则进行修改.在必要的地方,会在webpack.config.js中设置特殊的参数来跑源码,例如本例会使用module:{rules:[...]}来测试,基本上测试参数 ...

  10. jQuery在线引用地址(全)

    转:https://www.cnblogs.com/lmyau/p/7736269.html 1.官网jquery压缩版引用地址: 3.1.1版本: <script src="http ...