统计有几种邮箱地址。

邮箱名类型:local@domain

规则:1. local中出现"."的,忽略。 a.bc=abc

   2. local中出现"+"的,+以及之后的local全部忽略。 a+bc=a

思路:

利用set存,水题没啥好说的

Runtime: 20 ms, faster than 96.66% of C++ online submissions for Unique Email Addresses.

class Solution
{
public:
int numUniqueEmails(vector<string> &emails)
{
set<string> aset;
for (string s : emails)
{
bool local = true;
bool hasPlus = false;
string temp="";
for (char c : s)
{
if (c == '@')
local = false;
if (c == '+' && local)
hasPlus = true;
if ((c == '.' || hasPlus) && local)
continue;
temp.push_back(c);
}
aset.insert(temp);
}
return aset.size();
}
};

[leetcode] 929. Unique Email Addresses (easy)的更多相关文章

  1. [LeetCode] 929. 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, in ali ...

  3. LeetCode 929.Unique Email Addresses

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

  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. Linux --- 程序后台运行的几种方法

    有时候我们运行一个程序,耗时比较长,所以在快下班的时候或是网络不稳定的时候就比较抓狂. 今天分享几个我在工作中用到的把程序放在后台运行的方法. nohup $ nohup --h Usage: noh ...

  2. 在centos7上安装Docker CE

    Docker CE的基本安装 https://docs.docker.com/engine/installation/linux/docker-ce/centos/ 一.系统要求 1.安装Docker ...

  3. JVM(六):探究类加载过程-下

    JVM(六):探究类加载过程-下 上文说了类加载过程的5个阶段,着重介绍了各个阶段做的工作.在本文中,我们对执行加载阶段的主体进行探讨,学习类加载器的模型和逻辑,以及我们该如何自定义一个类加载器. 定 ...

  4. Tido 习题-二叉树-最高分

    题目描述 老师想知道从某某同学到某某同学当中,分数最高的是多少.现在请你编程模拟老师的询问.当然,老师有时候需要更新某位同学的成绩. 输入 输入包含多组测试数据.每组输入第一行是两个正整数N和M(0& ...

  5. Django之Cookie Session详解,CBV,FBV登陆验证装饰器和自定义分页

    Cookie Session和自定义分页   cookie Cookie的由来 大家都知道HTTP协议是无状态的. 无状态的意思是每次请求都是独立的,它的执行情况和结果与前面的请求和之后的请求都无直接 ...

  6. kali 源文件 更改和使用 更新日期:2018.04.21

    我的公众号,正在建设中,欢迎关注: 0x01 源文件格式: kali下常用的更新命令有: apt-get install update和apt-get install upgrade,update是下 ...

  7. vue路由传参query和params的区别(详解!)

    1.query使用path和name传参都可以,而params只能使用name传参. query传参: 页面: this.$router.push({ path:'/city',name:'City' ...

  8. C#—使用InstallerProjects打包桌面应用程序

    前言 打包桌面应用程序实在是一个不常使用的东西,偶尔使用起来经常会忘东忘西的耽误时间,因此,这篇文章多以图片记录过程,也是用于备忘. 下载打包工具 C#打包桌面应用程序有很多种方法,这里介绍一种使用M ...

  9. 两张图示轻松看懂 UML 类图

    一个类如何表示 第一格为类名 第二格为类中字段属性 格式:权限 属性名:类型 [ = 默认值 ] 权限:private.public .protected.default,它们分别对应 -.+.#.~ ...

  10. centos6.5虚拟机配置Nat模式连接外网

    想来在虚拟机上搭点软件,于是乎就想让虚拟机连上外网,就用到了Nat模式,自己对网络了解不是太深,以至于配置联网花了一下午.总结下联网步骤. (1)点击虚拟网络编辑器 (2)注意以下几点标红处 (3)点 ...