Use hashmaps in hard problems when:
You need to count occurrences or track frequencies in a sliding window
You're looking for pairs or subarrays with a specific sum or property
You need coordinate compression or value-to-index mapping
You're implementing a cache with specific eviction rules
The pattern: define what lookup you need, then design keys and values to support that lookup in .