Dictionaries as Lookup Tables
Map keys to values for fast access.
The Dictionary Idea
A dictionary maps keys to values, letting you fetch a stored answer by name instead of scanning. It is your contest lookup table. 🔑
Constant-Time Access
Like a set, a dict hashes the key, so reading and writing are roughly O(1). That speed is why it replaces slow linear searches.
All lessons in this course
- Sets for Membership and Dedup
- Dictionaries as Lookup Tables
- Counter and defaultdict in Action
- Group and Bucket with a Map