Study guide
Learn the patterns, one picture at a time
Every problem in weeks 1–4, explained for complete beginners: the idea in plain English, an animated step-by-step walkthrough, and the solution in JavaScript and Python with every line explained.
How to use this guide
- 1
Read the week overview first
It explains the data structures and patterns in plain English, with templates in JavaScript and Python.
- 2
Try each problem before reading
Open it on LeetCode, think for 20–30 minutes, and only then read the study page. Struggling first is how it sticks.
- 3
Play the visualizations
Step through them slowly. Read each caption: it says what happens and why. Then predict the next step before you press Next.
- 4
Re-type the code, don't copy it
Close the page and write the solution from memory in your language. Mark it complete when you can.
The four weeks
How to read the visualizations
Every picture uses the same colours, so once you learn them here they mean the same thing on every page. Boxes are values, and the small numbers under them are theirindexes (positions, starting at 0). Labelled arrows like i arepointers: variables that remember a position.
- 40
- 11
- 52
- 33
look up 5: found
| number | index |
|---|---|
| 4 | 0 |
| 1 | 1 |
| 5 | 2 |
- Looking at now
- Comparing with
- Answer
- Not found
- Just added
- Inside the window
- Already processed
- Ignored
- Controls: Play runs the steps automatically; Next and Previous move one step; the slider jumps anywhere. Click the player, then use ← → and the space bar.
- Caption: the sentence under the picture explains what just happened and why. Read it every step.
- Code panel: the highlighted line is the one running right now. Switch between JavaScript and Python anywhere and the choice is remembered on every page.