Hash Maps
Trade a little memory for O(1) answers to "have I seen this before?"
5 lessons · ~47 min · free
By the end you can
- Replace nested-loop searches with one-pass dictionary lookups
- Count frequencies and compare them for anagram-style problems
- Use the seen-before pattern for duplicates and pair sums
- Combine prefix sums with a hash map to count subarrays hitting a target
- Tell hash map problems apart from sorting and window problems
Lessons
Start the course- The lookup you repeat a million times8 minWhere the pattern comes from: nested scans that keep re-asking the same question a dict answers instantly.
- Counting things9 minFrequency maps: anagrams, majority elements, and the Counter habits that make them one-liners.
- The seen-before pattern10 minDuplicates, complements, and two-sum done properly: check the map before you add to it.
- Prefix sums plus a hash map12 minSubarray sum equals k: running totals and the "how often have I seen sum minus k" trick.
- Spotting hash map problems8 minPairs, counts, and uniqueness cues; where dicts lose to sorting; the templates side by side.
The account is free and so is every lesson. It unlocks the courses and saves your progress.
Practice it after
The final lesson links here too: real interview questions that test this pattern, in an editor with execution and AI feedback.