题目标签: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. 利用反射重写toString()方法

    为了方便输出对象,Object类提供了toString()方法.但是该方法的默认值是由类名和哈希码组成的,实用性并不强.通常需要重写该方法以提供更多的信息.本实例使用反射输出类的包.类的名字.类的公共 ...

  2. Python 语言搭建SELENIUM测试环境,搭建过程记录。

    第一步,安装Python: 第二步,安装SetupTools: 第三步,安装Pip: 第四步,安装selenium(for python) 第五步,新建第一个基于Firefox的测试用例 上述 只是步 ...

  3. css中常见几种float方式以及倒计时(刷新页面不清)

    css中常见几种float方式 http://jingyan.baidu.com/article/72ee561a670269e16138dfd5.html <script type=" ...

  4. MERGE INTO USING用法

    MERGE INTO [your table-name] [rename your table here] USING ( [write your query here] )[rename your ...

  5. WebAssembly 上手

    安装 Mac 上最便捷的安装方式当然是通过 Homebrew: $ brew install emscripten 安装好之后讲道理就已经自动配置好一切,然后 emcc 命令便可用了. 下面看非 Ho ...

  6. 带返回值的线程Callable

  7. Iframe用法精析

    String.prototype.match()中正则表达式的g标识存在的时候,函数不会捕获子表达式中的内容,不存在的时候可以. RegExp.prototype.exec()中g的存在只会影响,Re ...

  8. Oracle 回滚(ROLLBACK)和撤销(UNDO)

    一.回滚(ROLLBACK)和撤销(UNDO) 回滚和前滚是保证Oracle数据库中的数据处于一致性状态的重要手段. 在9i版本以前 Oracle使用数据库中的回滚段来实现未提交数据或因系统故障导致实 ...

  9. 转来的——python webdriver自动化测试初步印象——转来的

    python webdriver自动化测试初步印象 以下示例演示启动firefox,浏览google.com,搜索Cheese,等待搜索结果,然后打印出搜索结果页的标题 from selenium i ...

  10. JavaScript 面向对象的编程(三) 类的继承

    定义父类和子类的继承关系 //声明父类 function SuperClass(){ this.superValue = true; } //为父类添加共有方法 SuperClass.prototyp ...