function groupTitles(strs) {
const hashMap = {};
for (let word of strs) {
const count = new Array(26).fill(0);
for (let char of word) {
const index = char.charCodeAt(0) - 'a'.charCodeAt(0);
count[index] = +1;
}
if (count in hashMap) {
hashMap[count].push(word);
} else {
hashMap[count] = [word];
}
}
return hashMap;
}
var titles = [“duel”,“dule”,“speed”,“spede”,“deul”,“cars”]
var gt = groupTitles(titles)
var query = “spede”
for (var [_, g] of Object.entries(gt)) {
if (g.includes(query)){
console.log(g)
}
}