-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWC_1_2_EmailFeature.java
More file actions
40 lines (28 loc) · 1.08 KB
/
WC_1_2_EmailFeature.java
File metadata and controls
40 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
public class WC_1_2_EmailFeature {
public static void numUniqueEmails(String[] emails) {
Set<String> set = new HashSet<>();
for (String email : emails) {
String localName = email.split("@")[0];
String domainName = email.split("@")[1];
localName = localName.replace(".", "");
int index = localName.indexOf('+');
if (index != -1) {
localName = localName.substring(0, index);
}
set.add(localName + "@" + domainName);
}
System.out.println(set.size());
}
public static void main(String[] args)
{
Scanner reader = new Scanner(System.in);
String[] inputLine = new String[1000];
String input = reader.nextLine();
inputLine = input.split(" ");
numUniqueEmails(inputLine);
}
}