package main

import (
"fmt"
"strings"
) func numUniqueEmails(emails []string) int {
var dic map[string]int
dic = make(map[string]int)
for _, s := range emails {
strArr := strings.Split(s, "@")
localname := strArr[]
domainname := strArr[]
plusIndex := strings.Index(localname, "+")
if plusIndex > {
localname = localname[:plusIndex]
}
localname = strings.Replace(localname, ".", "", -)
realmail := localname + "@" + domainname
_, ok := dic[realmail]
if ok {
//found realmail
} else {
dic[realmail] =
}
}
return len(dic)
} func main() {
emails := []string{"test.email+alex@leetcode.com", "test.e.mail+bob.cathy@leetcode.com", "testemail+david@lee.tcode.com"}
num := numUniqueEmails(emails)
fmt.Println(num)
}
public class Solution
{
public int NumUniqueEmails(string[] emails)
{
var dic = new Dictionary<string, int>();
foreach (var email in emails)
{
var mails = email.Split('@');
var localname = mails[];
var domainname = mails[]; var plusIndex = localname.IndexOf('+');
if (plusIndex >= )
{
localname = localname.Substring(, plusIndex);
}
localname = localname.Replace(".", "");
var realmail = localname + "@" + domainname; if (!dic.ContainsKey(realmail))
{
dic.Add(realmail, );
}
}
return dic.Count;
}
}

leetcode929的更多相关文章

  1. [Swift]LeetCode929. 独特的电子邮件地址 | Unique Email Addresses

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

  2. Leetcode929.Unique Email Addresses独特的电子邮件地址

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

  3. leetcode929 Unique Email Addresses

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

随机推荐

  1. NoSQLUnit

    NoSQLUnit Core Overview Unit testing is a method by which the smallest testable part of an applicati ...

  2. mysql和redis加入到windows服务

    mysql加入到windows服务: mysqld --install  Mysql5.6 mysqld --remove mysql5.6  从windows的服务中删除mysql服务 net st ...

  3. 使用 phpStudy + VSCODE 进行 PHP 断点调试

    使用 phpStudy + VSCODE 进行 PHP 断点调试 自己摸索过程有点曲折,但还是配置成功了,现分享如下. 原料 phpStudy 2018 VSCODE 配置过程 安装 phpStudy ...

  4. linux中tomcat内存溢出解决办法

    用命令 tail -f /root/apache-tomcat-6.0.20/logs/catalina.out(需要找到tomcat路径) 查看日志,查看是否有错误 linux中tomcat内存溢出 ...

  5. window.open 和 location.href 区别

    window.open():可以在一个网站上打开另外的一个网站的地址 window.location():只能在一个网站中打开本网站的网页

  6. Vue 介绍

    1. 条件 效果图. 如果seen为false,文字将消失 2. 循环 script里定义数据 效果 3. 事件处理 效果如下图, hello world被逆转了

  7. C# 正则表达式 判断各种字符串(如手机号)

    using System; using System.Text.RegularExpressions; namespace MetarCommonSupport { /// <summary&g ...

  8. 【python】class之super关键字的作用

    在Python类的方法(method)中,要调用父类的某个方法,在Python 2.2以前,通常的写法如代码段1: 代码段1: class A: def __init__(self):    prin ...

  9. MVC框架请求处理

    为开发团队选择一款优秀的MVC框架是件难事儿,在众多可行的方案中决择需要很高的经验和水平.你的一个决定会影响团队未来的几年.要考虑方面太多: 简单易用,以提高开发效率.使小部分的精力在框架上,大部分的 ...

  10. ghost系统下,C#获取时间带星期几的解决办法

    cmd   regedit打开注册表,进入到[HKEY_USERS\.DEFAULT\Control Panel\International]  ,然后1.将键 sDate 的值由 / 改为 - 2. ...