Hash Map Practice Questions
Ten interview problems that all collapse to the same idea: “if I knew whether I’d seen this before, the answer would be one line.” The hash map is what makes “knowing” O(1).
Two related problems live in earlier chapters: Two Sum (which is the canonical example) and Top K Frequent Elements (which combines a counter with a heap). Same pattern, different angles.
Easy
| Problem | Pattern | Status |
|---|---|---|
| Contains Duplicate | Seen-set | Available |
| Valid Anagram | Frequency comparison | Available |
| First Unique Character in a String | Frequency count | Available |
| Intersection of Two Arrays | Set intersection | Available |
| Happy Number | Cycle detection via set | Available |
Medium
| Problem | Pattern | Status |
|---|---|---|
| Group Anagrams | Signature → bucket | Available |
| Longest Substring Without Repeating Characters | Sliding window + last-seen | Available |
| Subarray Sum Equals K | Prefix-sum + count map | Available |
| Insert Delete GetRandom O(1) | HashMap + array swap-and-pop | Available |
| LRU Cache | HashMap + doubly linked list | Available |
More Practice (Coming Soon)
| Problem | Pattern | Status |
|---|---|---|
| Isomorphic Strings | Bijection via two maps | Coming Soon |
| Word Pattern | Bijection by character | Coming Soon |
| Longest Consecutive Sequence | Hash set + smart starts | Coming Soon |
| Top K Frequent Words | Counter + heap + tie-break | Coming Soon |
| Substring with Concatenation of All Words | Sliding window + counter | Coming Soon |
| Find All Anagrams in a String | Sliding-window counter | Coming Soon |
| Daily Temperatures | Monotonic stack + lookup | Coming Soon |
| Design Twitter | HashMap + heap-of-lists | Coming Soon |
| LFU Cache | HashMap + frequency buckets | Coming Soon |