📚 PracticeMediumAlgorithm ProblemCoding Ready
Group Anagrams
hash-tablestringsorting
LeetCode #49
Updated Dec 20, 2025
Question
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
LeetCode: Group Anagrams
Example:
Input: strs = ["eat","tea","tan","ate","nat","bat"]
Output: [["bat"],["nat","tan"],["ate","eat","tea"]]
Input: strs = [""]
Output: [[""]]
Input: strs = ["a"]
Output: [["a"]]
Hints
Hint 1
Anagrams will have the same characters when sorted. Can you use the sorted string as a key?
Hint 2
Use a hash map where the key is the "signature" of the anagram group (like sorted string), and the value is the list of words.
Hint 3
Alternatively, you could use character counts as the key instead of sorted strings. Which is more efficient?
Your Solution
python
Auto-saves every 30s
Try solving the problem first before viewing the solution
Learning Resources
Related Problems
0:00time spent