Skip to content

Commit

Permalink
Merge pull request neetcode-gh#1394 from loczek/929-Unique-Email-Addr…
Browse files Browse the repository at this point in the history
…esses

Create: 929-Unique-Email-Addresses.ts
  • Loading branch information
Ahmad-A0 authored Nov 2, 2022
2 parents bd5452d + af1b5bb commit a90298f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions typescript/929-Unique-Email-Addresses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function numUniqueEmails(emails: string[]): number {
const unique = new Set();

for (const email of emails) {
let [local, domain] = email.split('@');
local = local.split('+')[0];
local = local.split('.').join('');
unique.add(local + '@' + domain);
}

return unique.size;
}

0 comments on commit a90298f

Please sign in to comment.