Check whether 2 strings are anagrams of each other?
Respostas da entrevista
Sigiloso
7 de set. de 2017
Sort the strings and compare the results. If equal, anagrams.
1
Sigiloso
27 de set. de 2017
This could be done way easier:
const areAnagrams = (str1, str2) => {
const dict = {};
total = 0;
for(let i = 0; i str2.length -1) {
return false;
}
total += (str1.charCodeAt(i)-str2.charCodeAt(i))
}
return total === 0;
}