Closed congr closed 5 years ago
class Solution {
public int numUniqueEmails(String[] emails) {
Set<String> set = new HashSet();
for (String s : emails) {
int at = s.indexOf("@");
String local = s.substring(0, at);
String domain = s.substring(at, s.length());
String[] r = local.split("/+"); // !!!
String t = r[0].replaceAll(".", "");
set.add (t + domain);
}
return set.size();
}
}
https://leetcode.com/problems/unique-email-addresses/
Example 1: