Hunt through a hash map: 12 levels of put, get, collisions and resizing. A hash table game that shows why O(1) can turn into O(n).
A hash map stores data in "buckets" chosen by a hash function. At Mas Bayu's desk the buckets are lockers 0 to 7: a key word is turned into a number (the sum of its character codes), divided by 8, and the remainder (modulo) is its locker number.
A collision happens when two different keys give the same locker. Chaining handles it with a chain (a linked list) on every locker: a new deposit hangs at the end of that locker's chain instead of moving to another locker.
A hash set checks for duplicates in O(1): before add, check has(). The same key always lands in the same locker, so looking along that one locker's chain is enough. Comparing every pair takes O(n²); a hash set makes it O(n).
The Two Sum pattern: for each number x, check whether (target - x) is already in the map. If it is, the pair is found. If not, store x. One pass, O(n), not O(n²).
Anagram grouping: use the letter count as the key. "abc" and "cab" have the same signature, "a1b1c1", so they land in the same locker and join the same group, automatically.
The caching pattern: before computing or fetching, check the map. If it's there, return it (a hit), O(1). If not, compute it, then store it. Memoization uses the same idea for expensive results.