题目标签:String

  题目说明 有两个规则针对于 local name。 所以先把local name 和 domain name 分开。

  两个规则是:

    rule 1:'.' 会被去除。 (利用replace 把 '.' 换成 '')

    rule 2:'+' 之后的所有东西都会被 去除。(利用substring 把 '+' 之后的去除)

Java Solution:

Runtime beats 34.05%

完成日期:12/08/2018

关键点:substring 和 replace

class Solution
{
public int numUniqueEmails(String[] emails)
{
Set<String> set = new HashSet<>(); for(String email : emails)
{
String editedEmail = editEmail(email); set.add(editedEmail); } return set.size();
} private String editEmail(String email)
{
int index = email.indexOf('@');
String str_1 = email.substring(0, index);
String str_2 = email.substring(index); if(str_1.contains("+"))
str_1 = str_1.substring(0, str_1.indexOf('+')); str_1 = str_1.replace(".", ""); return str_1 + str_2;
}
}

参考资料:N/A

LeetCode 题目列表 - LeetCode Questions List

题目来源:https://leetcode.com/

LeetCode 929. Unique Email Addresses (独特的电子邮件地址)的更多相关文章

  1. 【LeetCode】Unique Email Addresses(独特的电子邮件地址)

    这道题是LeetCode里的第929道题. 题目要求: 每封电子邮件都由一个本地名称和一个域名组成,以 @ 符号分隔. 例如,在 alice@leetcode.com中, alice 是本地名称,而  ...

  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. Leetcode929.Unique Email Addresses独特的电子邮件地址

    每封电子邮件都由一个本地名称和一个域名组成,以 @ 符号分隔. 例如,在 alice@leetcode.com中, alice 是本地名称,而 leetcode.com 是域名. 除了小写字母,这些电 ...

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

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

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

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

  6. LeetCode 929.Unique Email Addresses

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

  7. LeetCode 929 Unique Email Addresses 解题报告

    题目要求 Every email consists of a local name and a domain name, separated by the @ sign. For example, i ...

  8. 929. Unique Email Addresses

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

  9. 【Leetcode_easy】929. Unique Email Addresses

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

随机推荐

  1. JS高级——Blob处理二进制文件

    https://www.cnblogs.com/hhhyaaon/p/5928152.html

  2. java 基础学习笔记 - 安装

    1. 从www.sun.com中 下载jdk安装包 2. 执行安装包,安装jdk ,jre(Java运行环境) 3. 配置path路径 增加jdk下的bin目录. 配置完后需要重启cmd窗口,因为cm ...

  3. Masonry 原理与使用说明

    原理: 1)约束生成:MASConstraintMaker: 2)缺省补齐: - (void)setSecondViewAttribute:(id)secondViewAttribute { if ( ...

  4. CAD与用户交互在图面上选择一个实体(com接口VB语言)

    主要用到函数说明: IMxDrawUtility::GetEntity 与用户交互到在图面上选择一个实体,详细说明如下: 参数 说明 [out] IMxDrawPoint** pPickPoint 返 ...

  5. 梦想CAD控件关于比较问题

    全图比较 怎么比较两个CAD图纸文件修改前后的不同部分呢?在工程图纸设计中,我们更多情况下可能需要对同一张工程图的前后修改部分进行对比,以确定工程图纸的改动部分及追溯原因,本教程演示了几种常见的比较方 ...

  6. vue过渡 & 动画---进入/离开 & 列表过渡

    (1)概述 Vue 在插入.更新或者移除 DOM 时,提供多种不同方式的应用过渡效果.包括以下工具: 在 CSS 过渡和动画中自动应用 class 可以配合使用第三方 CSS 动画库,如 Animat ...

  7. HDU多校Round 5

    Solved:3 rank:71 E. Everything Has Changed #include <bits/stdc++.h> using namespace std; const ...

  8. 汇编学习pushl, popl

  9. maven入门链接

    http://www.cnblogs.com/now-fighting/p/4857625.html

  10. 常用Linux命令_20190211

    1.创建文件夹:mkdir 文件夹名称 2.查看IP地址信息:ipconfig -a 3.查看内存使用情况:free -m 4.查看CPU使用情况:top 5.查看磁盘使用情况:df -a/-h 6. ...