Topics / Hashing
#️⃣
Hashing
Hash maps and sets — the O(1) lookup that turns hard problems into easy ones.
Why learn Hashing?
-
Converts many O(n²) brute forces into O(n) solutions.
-
Used in over half of medium-level interview problems.
-
Powers caches, dedup, deduplication, and database indexes.
What you can build with Hashing
Two-sum-style lookups Frequency counting Sub-array sum and prefix-hash patterns
Hashing tutorials
7 articlesHand-written tutorials, ordered as a recommended learning path.
- 01 Hashing & Hash Maps How hash functions, hash maps, and hash sets work — the intuition behind buckets and collisions, chaining vs open addressing, average and worst-case complexity, and the Python containers built on them.
- 02 Hashing — Practice Eight classic hash map problems with worked Python solutions — Two Sum, Group Anagrams, Subarray Sum Equals K, Longest Consecutive Sequence, Top K Frequent Elements, and more.
- 03 Group Anagrams Solve LeetCode Group Anagrams cleanly with a hash map keyed by sorted strings or character counts. Includes complexity analysis and interview talking points.
- 04 Two Sum A complete walkthrough of LeetCode 1 Two Sum. We move from the obvious nested loop to a single-pass hash map and dissect why it works.
- 05 Valid Anagram A complete walkthrough of LeetCode Valid Anagram. Compare the sorting approach with the optimal hash map counting solution and learn how to explain it in interviews.
- 06 Longest Consecutive Solve LeetCode 128 Longest Consecutive Sequence in O(n) using a hash set and a start-of-run check. Walkthrough, edge cases, and interview script.
- 07 Top K Frequent Solve LeetCode 347 Top K Frequent Elements with both a min-heap and a bucket sort approach. Trade-offs, complexity, and interview-ready walkthrough.