#️⃣ JavaScript Hashing — Topic Index
Hashing maps keys to values using a hash function, enabling O(1) average-time lookups, inserts, and deletes. JavaScript provides Map and Set as built-in hash structures.
Topics Covered
| # | Topic | Key Concepts |
|---|---|---|
| 1 | Basics | Map, Set, frequency counting, plain objects |
| 2 | Patterns | Two-sum, grouping, prefix sums, sliding window |
| 3 | Interview Questions | 25 classic problems |
Why Hashing?
- O(1) average lookup/insert/delete — transforms O(n²) brute force into O(n)
- Frequency counting — character/word counts in O(n)
- Prefix sums — subarray problems solved with running sum maps
- Deduplication — instantly check if element was seen before
Common Patterns
- Two-pointer complement lookup —
target - xin Map - Frequency map — count occurrences, find majority element
- Prefix sum + Map — subarray sum equals k
- Sliding window + freq — minimum window substring, anagrams
- Set for O(1) membership — consecutive sequences, duplicates