MCPcopy Create free account
hub / github.com/camilamaia/jornada-big-tech / Solution

Class Solution

leetcode/src/UniqueEmailAddressesLeetCodeSolution.java:1–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution {
2 public int numUniqueEmails(String[] emails) {
3 // hash set to store all the unique emails
4 Set<String> uniqueEmails = new HashSet<>();
5
6 for (String email : emails) {
7 // split into two parts local and domain
8 String[] parts = email.split("@");
9
10 // split local by '+'
11 String[] local = parts[0].split("\\+");
12
13 // remove all '.', and concatenate '@' and append domain
14 uniqueEmails.add(local[0].replace(".", "") + "@" + parts[1]);
15 }
16
17 return uniqueEmails.size();
18 }
19}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected