Intermedio30 pts
Group Anagrams
Traducción al español en progresoEl contenido detallado de esta lección aún se está traduciendo. Mientras tanto, se muestra en inglés.
Given an array of strings, group the anagrams together. Anagrams are words with the same characters in different order. Algorithm: Sort each word's characters and use as key in a hash map. Example: ['eat','tea','tan','ate','nat','bat'] → Groups: ['eat','tea','ate'], ['tan','nat'], ['bat']
Entrada
Line 1: n (number of words). Line 2: n space-separated words.
Salida
Each group on a line, words space-separated, groups sorted alphabetically by first word, words within groups sorted.
Ejemplo
6 eat tea tan ate nat bat
Esperado
ate eat tea bat nat tan
Loading editor…
Resultado
Sin salida aún. Ejecuta tu código para ver resultados.