Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
A set is effectively just a hash table, so it is average-case O(1) and worst-case O(n).
The actual time taken to determine if an item is in the hash depends on how many buckets are used for the table, and how many items are in the bucket.
If we had one bucket, or by sheer coincedence all of our items ended up in the same bucket, we'd have O(n) complexity. We would have to iterate through the bucket until we found our item. This is our worst-case scenario.
If we had x buckets, and we assume that we've got some pretty uniform distribution between them, we'd have O(1) overall complexity, and a O(n) complexity for the bucket your item is in. That is still O(1) complexity however.
You can think of putting an item in a bucket as:
and then determining if an item is in a bucket as:
*Disclaimer that this is simplified to hell and back