โ† Coding Interview Prep (LeetCode) learning path
Coding Interview Prep (LeetCode) ยท Module 4 of 10

Hashing

Hash maps and sets give fast lookups to remove inner loops.

๐Ÿ“– Key ideas

  1. A hash map stores key to value with average O(1) lookup.
  2. Two Sum: store each number's index and check target - x.
  3. Counting frequencies solves anagram and majority questions.
  4. Hash sets detect duplicates in one pass.
  5. Trade-off: extra memory for speed.
๐Ÿ’ก Real-life example: Like a class register by roll number: jump straight to a student instead of reading the whole list.
Hash mapKey to value store with fast lookup
Hash setStores unique keys only
Frequency countHow often each item appears
Complementtarget minus the current value