Skip to content

Commit ff18ff9

Browse files
authored
Create Solution.java
1 parent 59a889d commit ff18ff9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int numUniqueEmails(String[] emails) {
3+
Set<String> set = new HashSet<>();
4+
for (String email : emails) {
5+
int index = email.indexOf('@');
6+
String local = email.substring(0, index);
7+
String domain = email.substring(index);
8+
index = local.indexOf('+');
9+
if (index != -1) {
10+
local = local.substring(0, index);
11+
}
12+
local = local.replace(".", "");
13+
set.add(local + domain);
14+
}
15+
return set.size();
16+
}
17+
}

0 commit comments

Comments
 (0)