Last active
February 7, 2019 10:12
-
-
Save CodeDotJS/ea9eac63b5ae9a36fd77827e6c46f3ee to your computer and use it in GitHub Desktop.
Unique Email Address - LeetCode Solution.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const numUniqueEmails = emails => { | |
const listofMails = []; | |
const storeUniqueEmails = []; | |
const mailLength = emails.length; | |
for (let i = 0; i <= mailLength - 1; i++) { | |
const filteredName = emails[i].split('+')[0].replace(/\./g, '') + '@' + emails[i].split('@')[1]; | |
listofMails.push(filteredName); | |
} | |
const len = listofMails.length; | |
for (let j = 0; j < len; j++) { | |
if (storeUniqueEmails.indexOf(listofMails[j]) === -1) { | |
storeUniqueEmails.push(listofMails[j]); | |
} | |
} | |
return storeUniqueEmails.length; | |
}; | |
console.log(numUniqueEmails(["[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]", "[email protected]","[email protected]","[email protected]"])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment