โ† Core Algorithms
#6 most askedVery commonMediumHash map

Group Anagrams

New to Hash map? Learn it from scratch first
Hash Maps & Sets โ†’
๐Ÿข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.
I was asked this

Group words that are anagrams of each other (same letters, different order). Return the groups in any order.

["eat", "tea", "tan", "ate", "nat", "bat"] โ†’ [["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]

๐Ÿงช Practice

Write your solution, then press Run tests. Explain your approach out loud as you go.

Python
def group_anagrams(words):
    pass

Output appears here. Press Run or Ctrl/โŒ˜ + Enter.

Try it first. Struggling for a few minutes is how it sticks.