core practice · coding problem
Group Anagrams
LeetCode #49 — Group Anagrams. Solve on LeetCode, then implement here if you want it in your drill queue. https://leetcode.com/problems/group-anagrams/
The mechanism
A hash map trades memory for time: it turns an O(n) scan for "have I seen this?" into an O(1) lookup. Most array problems that feel quadratic collapse to linear once you ask what you would store in a map keyed by value, complement, or frequency.
Expected evidence
Pass all LeetCode test cases for this problem.
Try this drill in the practice workspace →
Hints when you need them
- Pattern hint: array hashing.
- Start with brute force, then optimize time/space.
- Write down invariants before coding.
Watch for these mistakes
- Reaching for nested loops before asking "what would a hash map key on?"
- Mutating a collection while iterating it
- Forgetting hash maps have no order — sort separately if order matters