DSA · interactive
Hash map: group anagrams in one pass
Anagrams use the same letters. Give every word a key that is equal for anagrams, then use a hash map from key to group. One lookup per word, no comparing every pair.
Input
- eat
- tea
- tan
- ate
- nat
- bat
Hash map · key → group
- empty
An empty map. Press Play to read the words one at a time.
Key
1 Go through the list once, left to right.
—
2 3 4 5
Now solve it
Arrays & Hashing: 19 problems
See all →In production
Tools and technologies
Grouping by a computed key is how databases and data tools group rows, not just an interview trick.
Not tied to one language — use these names when you search docs or design a system.