Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7c0bffb

Browse files
authored
Merge pull request6boris#50 from hiepndd/develop
Contribute solution problem 0929 and add me to file README.md
2 parentsccc608b +ac3b56e commit7c0bffb

File tree

4 files changed

+64
-5
lines changed

4 files changed

+64
-5
lines changed

‎README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#📝 awesome-golang-leetcode
22

3-
43
LeetCode of algorithms with golang solution(updating:smiley:).
54

65
<palign="center">
@@ -29,16 +28,15 @@ LeetCode of algorithms with golang solution(updating:smiley:).
2928
</a>
3029
</p>
3130

32-
33-
3431
##Contributors
3532

3633
Thanks goes to these wonderful people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)):
3734

3835
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section-->
3936
<!-- prettier-ignore-->
40-
| [<img src="https://avatars0.githubusercontent.com/u/26195433?v=4" width="100px;" alt="Kyle Liu "/><br /><sub><b>Kyle Liu </b></sub>](https://kyle.link)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=kylesliu "Code") [📝](#blog-kylesliu "Blogposts") [🎨](#design-kylesliu "Design") [📖](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=kylesliu "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/34671440?v=4" width="100px;" alt="hapiman2"/><br /><sub><b>hapiman2</b></sub>](https://github.com/hapiman2)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=hapiman2 "Code") | [<img src="https://avatars0.githubusercontent.com/u/7567048?v=4" width="100px;" alt="hapiman"/><br /><sub><b>hapiman</b></sub>](https://github.com/hapiman)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=hapiman "Code") | [<img src="https://avatars2.githubusercontent.com/u/26058740?v=4" width="100px;" alt="sihg yu"/><br /><sub><b>sihg yu</b></sub>](https://github.com/sihgyu)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=sihgyu "Code") | [<img src="https://avatars3.githubusercontent.com/u/38197795?v=4" width="100px;" alt="plusweiwei"/><br /><sub><b>plusweiwei</b></sub>](https://github.com/plusweiwei)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=plusweiwei "Code") | [<img src="https://avatars0.githubusercontent.com/u/6274967?v=4" width="100px;" alt="Sandy"/><br /><sub><b>Sandy</b></sub>](https://openset.github.com)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=openset "Code") |
37+
| [<img src="https://avatars0.githubusercontent.com/u/26195433?v=4" width="100px;" alt="Kyle Liu "/><br /><sub><b>Kyle Liu </b></sub>](https://kyle.link)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=kylesliu "Code") [📝](#blog-kylesliu "Blogposts") [🎨](#design-kylesliu "Design") [📖](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=kylesliu "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/34671440?v=4" width="100px;" alt="hapiman2"/><br /><sub><b>hapiman2</b></sub>](https://github.com/hapiman2)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=hapiman2 "Code") | [<img src="https://avatars0.githubusercontent.com/u/7567048?v=4" width="100px;" alt="hapiman"/><br /><sub><b>hapiman</b></sub>](https://github.com/hapiman)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=hapiman "Code") | [<img src="https://avatars2.githubusercontent.com/u/26058740?v=4" width="100px;" alt="sihg yu"/><br /><sub><b>sihg yu</b></sub>](https://github.com/sihgyu)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=sihgyu "Code") | [<img src="https://avatars3.githubusercontent.com/u/38197795?v=4" width="100px;" alt="plusweiwei"/><br /><sub><b>plusweiwei</b></sub>](https://github.com/plusweiwei)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=plusweiwei "Code") | [<img src="https://avatars0.githubusercontent.com/u/6274967?v=4" width="100px;" alt="Sandy"/><br /><sub><b>Sandy</b></sub>](https://openset.github.com)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=openset "Code") | [<img src="https://avatars0.githubusercontent.com/hiepndd" width="100px;" alt="hiepndd"/><br /><sub><b>hiepndd</b></sub>](https://github.com/hiepndd)<br />[💻](https://github.com/kylesliu/awesome-golang-leetcode/commits?author=hiepndd "Code") |
4138
| :---:| :---:| :---:| :---:| :---:| :---:|
39+
4240
<!-- ALL-CONTRIBUTORS-LIST:END-->
4341

44-
This project follows the[all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
42+
This project follows the[all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#[929. Unique Email Addresses][title]
2+
3+
##Description
4+
5+
Every email consists of a local name and a domain name, separated by the @ sign.
6+
7+
For example, inalice@leetcode.com, alice is the local name, and leetcode.com is the domain name.
8+
9+
Besides lowercase letters, these emails may contain '.'s or '+'s.
10+
11+
If you add periods ('.') between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. For example, "alice.z@leetcode.com" and "alicez@leetcode.com" forward to the same email address. (Note that this rule does not apply for domain names.)
12+
13+
If you add a plus ('+') in the local name, everything after the first plus sign will be ignored. This allows certain emails to be filtered, for examplem.y+name@email.com will be forwarded tomy@email.com. (Again, this rule does not apply for domain names.)
14+
15+
It is possible to use both of these rules at the same time.
16+
17+
Given a list of emails, we send one email to each address in the list. How many different addresses actually receive mails?
18+
19+
**Example:**
20+
21+
```
22+
Input: ["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"]
23+
Output: 2
24+
Explanation: "testemail@leetcode.com" and "testemail@lee.tcode.com" actually receive mails
25+
26+
```
27+
28+
##NOTES
29+
30+
1 <= emails[i].length <= 100
31+
1 <= emails.length <= 100
32+
Each emails[i] contains exactly one '@' character.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package Solution
2+
3+
import (
4+
"strings"
5+
)
6+
7+
funcnumUniqueEmails(emails []string)int {
8+
emailSet:=map[string]bool{}
9+
for_,email:=rangeemails {
10+
parts:=strings.Split(email,"@")
11+
localName:=strings.Replace(strings.Split(parts[0],"+")[0],".","",-1)
12+
emailSet[localName+"@"+parts[1]]=true
13+
}
14+
returnlen(emailSet)
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package Solution
2+
3+
import (
4+
"testing"
5+
)
6+
7+
funcTestSolution(t*testing.T) {
8+
listTest:= []string{"test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"}
9+
got:=numUniqueEmails(listTest)
10+
want:=2
11+
ifgot!=want {
12+
t.Errorf("want '%d' but got '%d'",want,got)
13+
}
14+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp