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

Lessons

  1. 1The lookup you repeat a million times8 minWhere the pattern comes from: nested scans that keep re-asking the same question a dict answers instantly.
  2. 2Counting things9 minFrequency maps: anagrams, majority elements, and the Counter habits that make them one-liners.
  3. 3The seen-before pattern10 minDuplicates, complements, and two-sum done properly: check the map before you add to it.
  4. 4Prefix sums plus a hash map12 minSubarray sum equals k: running totals and the "how often have I seen sum minus k" trick.
  5. 5Spotting hash map problems8 minPairs, counts, and uniqueness cues; where dicts lose to sorting; the templates side by side.

Practice it after

Real interview questions that test this pattern, in an editor with execution and AI feedback.