[leetcode] 929. Unique Email Addresses (easy)
统计有几种邮箱地址。
邮箱名类型: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)的更多相关文章
- [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 (独特的电子邮件地址)
题目标签:String 题目说明 有两个规则针对于 local name. 所以先把local name 和 domain name 分开. 两个规则是: rule 1:'.' 会被去除. (利用re ...
- 929. Unique Email Addresses
929. Unique Email Addresses Easy 22766FavoriteShare Every email consists of a local name and a domai ...
- 【Leetcode_easy】929. Unique Email Addresses
problem 929. Unique Email Addresses solution: class Solution { public: int numUniqueEmails(vector< ...
- 【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 ...
随机推荐
- qt5.6 webengine兼容xp的编译方法
http://www.qtcn.org/bbs/read-htm-tid-62470.html http://stackoverflow.com/questions/31678657/qtwebeng ...
- LockWindowUpdate
//锁住listview防止反复刷新 LockWindowUpdate(Self.lvsearch.Handle); 貌似不太行,多用几下就卡住了 那个函数几乎不用 ...
- Rainyday.js – Rendering Raindrops with JavaScript
Posted · Category:GPL License,Tools 直击现场 The idea behind Rainyday.js is to create a JavaScript libra ...
- C语言实现常用数据结构——堆
#include<stdio.h> #include<stdlib.h> #define CAPACITY 20 /*堆有两个性质: * 1.结构性:堆必须是一颗完全二叉树 * ...
- 深入V8引擎-AST(1)
没办法了,开坑吧,接下来的几篇会讲述JavaScript字符串源码在v8中转换成AST(抽象语法树)的过程. JS代码在V8的解析只有简单的几步,其中第一步就是将源字符串转换为抽象语法树,非常类似于v ...
- centOS7.3 6忘记密码/修改root密码
RedHat最近升级了centos linux操作系统,更新为centos7,更新幅度之大,连红帽官方的认证RHCE也进行了升级,认证必须使用rhel7,可见红帽官方对centos7的重视程度. 最新 ...
- git常用总结
git 基本配置 安装git yum -y install git git全局配置 git config --global user.name "lsc" #配置git使用用户 g ...
- 跟我学SpringCloud | 第七篇:Spring Cloud Config 配置中心高可用和refresh
SpringCloud系列教程 | 第七篇:Spring Cloud Config 配置中心高可用和refresh Springboot: 2.1.6.RELEASE SpringCloud: Gre ...
- 使用 cxf的程序 在win10 测试部署时报空指针异常
2018-11-08 15:50:55.072 DEBUG 21524 --- [nio-8080-exec-1] o.s.b.w.s.f.OrderedRequestContextFilter : ...
- TreeView虚拟化跳转
使用ItemContainerGenerator.ContainerFromItem方法可以获取对应数据的UIElement . 但是如果使用了虚拟化技术,超出可见区域的UIElement就获取不到了 ...