iq.lab
Python starts when a code cell comes near or you run one

Module 3 · 5 lessons · about 7 hours 50 minutes

Arrays and hash maps

How a list sits in memory, how a hash map finds a key without searching, and the patterns they power: counting, seen-before, grouping by a key, and prefix sums.

Lessons
0/5
Exercises
0/36
Code
0/6
Problems
0/17
Checkpoint
Not taken

Already comfortable with this? Take the checkpoint cold. If you pass, move on and come back only for what you missed.

  1. 1How a list really worksA Python list is a block of numbered slots in memory with its items side by side. That one picture explains why reading any index takes one step, why append is cheap on average, why the front of a list is expensive, and how to build a grid that behaves.1 h 20 min
  2. 2How a hash map worksA dict or a set finds a key without searching everything it holds. The key's hash picks one bucket, and only that bucket is searched. Watch the buckets fill, collide and double, and learn why lookups are O(1) on average and O(n) at worst.1 h 25 min
  3. 3Counting and seen-beforeTwo notebooks that the rest of this module builds on. A dict from item to count answers "how many of each?", and a set or dict of what you have passed answers "have I met this before?". Two sum puts the second one to work.1 h 30 min
  4. 4Grouping by a keyOne walk with a dict from key to list puts every item in its group, and choosing the key is the whole problem. Then two more O(n) jobs: counts used as list positions to find the most frequent values, and a set that finds where each run of consecutive numbers starts.1 h 50 min
  5. 5Prefix sumsKeep a running total at every position and the sum of any stretch of a list becomes one subtraction. Add a dict that counts the totals seen so far, and one walk counts every stretch that adds up to a target.1 h 45 min
  6. Checkpoint12 questions. Pass with 80% to finish the module.

Problems for this module

The lessons teach some of these step by step (each says which). The rest are practice: try each in its target time, and solved problems come back for spaced re-solves.

Next moduleTwo pointers and sliding windows