Hash Map
⏱ Time: O(N)💾 Space: O(N)
Use a hash map or dictionary to store key-value pairs for O(1) average time complexity lookups.
🎯 When to Use
- ✓Fast lookups required
- ✓Counting frequencies
- ✓Mapping relationships
📝 Pseudocode
Hash Map TemplateO(N)
1function solve(arr): 2 map = new Map() 3 for item in arr: 4 map.set(item.key, item.value) 5 return map