Arrays & Hashing
Use hash maps, sets, and array manipulation to solve problems involving lookups, frequency counting, and element relationships.
- • Need O(1) lookup
- • Counting frequencies
- • Finding pairs/duplicates
- • String manipulation
- • Need sorted order
- • Need range queries
- • Memory is severely constrained
- • Forgetting edge cases (empty array, single element)
- • Off-by-one errors in indices
- • Not handling duplicates
Key Invariant
Hash maps trade space for time — O(1) lookup at the cost of O(n) memory