Week 1 · Day 1 of 42
Hashing: Frequency Count / Grouping
Count occurrences with a hash map (Counter in Python). O(1) lookup per element.
Sign in to tick off tasks and keep your progress on every device
Hashing - Frequency Count / Grouping
Tick the box when you have studied this pattern
- Count occurrences with a hash map (Counter in Python). O(1) lookup per element.
- Group elements by a computed key (e.g., sorted string for anagrams).
- Two Sum pattern: for each element, check if complement exists in the map.
- Prefix sum + hash map: count subarrays with a given sum in O(n).
Solve these
Try each one before reading a solution. Name the pattern out loud first.
Extra practice · 1 more problem
See it move
Spotted a mistake on this page?
Wrong formula, broken animation or confusing wording. Tell us and we will fix it.