统计有几种邮箱地址。

邮箱名类型: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. [铁人赛] ASP.NET Core 2 系列- 从头开始

    来势汹汹的.NET Core似乎要取代.NET Framework,ASP.NET也随之发布.NET Core版本.虽说名称沿用ASP.NET,但相较于ASP.NET确有许多架构上的差异,可说是除了名 ...

  2. oracle10g登录em后,提示“java.lang.Exception: Exception in sending Request :: null”

    出现错误时登录企业管理器时出现的界面 出现这种错误一般是因为没有设置时区,一般默认的是agentTZRegion=GMT,也就是GMT.所以大家只要设置了这个东西,然后重新启动dbconsole就可以 ...

  3. python 参考知识点

    本笔记仅作为有编程基础的童鞋在学习python时的参考资料,不适合零基础小白,并假设在你的电脑上已经正确安装了python环境,windows下需要配置环境变量,可以在终端窗口中执行以下命令 set ...

  4. hgoi#20190513

    T1-Felicity is Coming! 神奇宝贝的进化方案是一个全排列,假设有三种宝可梦,那么对应就可以有: (1,2,3)(1,3,2)(2,1,3)(2,3,1)(3,1,2)(3,2,1) ...

  5. spring_three

    转账案例 坐标: ; } } 创建增强类Logger.java /** * 用于记录日志的工具类,它里面提供了公共的代码 */ @Component("logger") @Aspe ...

  6. 移动IM开发指南3:如何优化登录模块

    <移动IM开发指南>系列文章将会介绍一个IM APP的方方面面,包括技术选型.登陆优化等.此外,本文作者会结合他在网易云信多年iOS IM SDK开发的经验,深度分析实际开发中的各种常见问 ...

  7. Spring Boot2(五):使用Spring Boot结合Thymeleaf模板引擎使用总结

    一.Thymeleaf概述 一般来说,常用的模板引擎有JSP.Velocity.Freemarker.Thymeleaf . SpringBoot推荐的 Thymeleaf – 语法更简单,功能更强大 ...

  8. MethodInterceptor-方法拦截器

    MethodInterceptor 方法拦截器,也就是aop拦截方法 1.使用示例 public interface MethodInterceptor extends Interceptor { O ...

  9. Java多线程学习(吐血超详细总结)

    Java多线程学习(吐血超详细总结) 林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 写在前面的话:此文只能说是java多线程的一个入门,其实 ...

  10. 苹果二代TWS无线耳机AirPods调研

    产品介绍 苹果AirPods二代自从2018年9月份上市以来,到现在将近一年的时间了,据江湖传闻,苹果AirPods的总售卖个数,已经超过了5000W部,这样价格的TWS耳机,能够卖那么多的量,估计也 ...