Search RU
Tasks / Algorithms / Grouping anagrams
Statement easy

Grouping anagrams

Implement `group_anagrams(words)`: group words that are anagrams of each other.

Anagrams are words that match after normalisation: case is ignored and
whitespace characters are dropped. For example, `"Listen"` and `"silent"` are
anagrams.

Output rules:

- groups follow the order in which their first word appears in the input;
- inside a group words keep their original order and duplicates are preserved;
- empty strings and whitespace-only strings normalise to an empty key and land in
one group;
- an empty input returns `[]`.

Example: `["listen", "silent", "enlist", "google", "gooegl"]` →
`[["listen", "silent", "enlist"], ["google", "gooegl"]]`.

Support Unicode: Cyrillic must work exactly like Latin.

Python
algorithmshash-mapstrings
solution.py Python 3.14
AI mentor

The AI mentor is available after you log in: it sees your attempt history and does not spend resources on anonymous requests.

Log in and ask
Hints 1 of 3 unlocked · attempts: 0
Hint 1

What do two anagrams have in common if you ignore the order of the letters?

Hint 2 — unlocks after 1 attempt
Hint 3 — unlocks after 3 attempts