| 1 | class 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected