Skip to content

Commit a90298f

Browse files
authored
Merge pull request neetcode-gh#1394 from loczek/929-Unique-Email-Addresses
Create: 929-Unique-Email-Addresses.ts
2 parents bd5452d + af1b5bb commit a90298f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function numUniqueEmails(emails: string[]): number {
2+
const unique = new Set();
3+
4+
for (const email of emails) {
5+
let [local, domain] = email.split('@');
6+
local = local.split('+')[0];
7+
local = local.split('.').join('');
8+
unique.add(local + '@' + domain);
9+
}
10+
11+
return unique.size;
12+
}

0 commit comments

Comments
 (0)