You are viewing a single comment's thread. Return to all comments →
I've the same, but I prefer using ES6 syntax. But your solution also fine. gj.
main = () => { const firstWord = readLine().split('') const secondWord = readLine().split('') let initialLettersCount = firstWord.length + secondWord.length firstWord.forEach((firstWordLetter) => { for (let j = 0; j < secondWord.length; j++) { if (firstWordLetter === secondWord[j]) { secondWord.splice(j, 1) initialLettersCount -=2 break } } }) console.log(initialLettersCount) }
Seems like cookies are disabled on this browser, please enable them to open this website
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
I've the same, but I prefer using ES6 syntax. But your solution also fine. gj.