Solución
solution.tsTypeScript
export function groupAnagrams(words: string[]): string[][] {
const group: Record<string, string[]> = {}
for (const word of words) {
const key = [...word].sort().join('')
if (!group[key])
group[key] = []
group[key].push(word)
}
const anagrams: string[][] = []
for (const key in group) {
anagrams.push(group[key].sort())
}
return anagrams.sort()
}0respuestas