Skip to content · ⁨Saltar al contenido⁩

Group anagrams · ⁨Agrupar anagramas⁩

English

Group anagrams

Two words are anagrams if they use exactly the same letters, like eat and tea. Group the anagrams together and return a list of groups.

The trick: sort the letters of each word to make a key — eat and tea both become aet. Words with the same key belong in the same group. Use a dictionary from key → list of words, and remember the order the keys first appear.

Español

Agrupar anagramas

Dos palabras son anagramas si utilizan exactamente las mismas letras, como eat y tea. Agrupe los anagramas juntos y devuelva una lista de grupos.

El truco: ordene las letras de cada palabra para crear una clave — eat y tea se convierten ambas en aet. Las palabras con la misma clave pertenecen al mismo grupo. Utilice un diccionario de clave → lista de palabras, y recuerde el orden en que aparecen por primera vez las claves.

Log in or create account · ⁨Iniciar sesión o crear cuenta⁩

IGCSE, A-Level & AP