Sets for Membership and Dedup
Test existence in constant time.
What a Set Buys You
A set stores unique items with no order, and its real power is answering 'is this here?' in roughly constant time. ⚡
Why Not Just a List
Checking membership in a list scans every element, so it is O(n). A set hashes the value and jumps straight to the bucket instead.
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