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.
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 askHint 1
What do two anagrams have in common if you ignore the order of the letters?