LC 49
LeetCode 49 · Medium

Group Anagrams

Group the strings that are anagrams of each other.

Hash map → · High frequency · Solve on LeetCode →

Try it

Step through the core mechanic. The simulator below runs the hash map shape this problem is built on.

Walk the pattern

No dedicated step-through for this one yet. The shape is Hash map — its pattern page has the interactive walkthrough, the reference implementation, and a five-problem progression that this problem sits inside.

The approach

Key each word by its sorted letters (or its 26-count tuple) and append into a hash map of key→list. The map values are the groups.

AspectValue
PatternHash map
Recognise it byBucket strings by a canonical key.
Time complexityO(n·k log k)
Space complexityO(n·k)
DifficultyMedium

Who asks it

Companies known to ask this problem, from public LeetCode company-tag aggregations. A signal of where to expect it, not a guarantee.