Data structures
Every coding pattern is built from a handful of structures: arrays, hash maps, stacks, queues, heaps, trees and graphs. Learn each one once, here, and the patterns become recipes you already have the ingredients for.
- Sam Why are there data structure lessons before the coding patterns?
- Priya Because every pattern is built from the same few structures. A hash map turns up in two sum, in sliding windows, in prefix sums and in grouping. A queue drives every breadth-first search. If you meet each structure half explained inside each pattern, it's confusing. So the beginner path teaches all twelve first, then starts the patterns.
- Sam Do I have to do all twelve?
- Priya If you're new to interviews, yes, in order. They're short. If you already know a structure, skim its table of operations and try its quiz. If both feel easy, move on.
- Sam What are the twelve?
- Priya Arrays and lists, then strings. Hash maps and hash sets. Linked lists. Stacks, then queues and deques. Heaps, which give you the smallest item fast. Trees, then binary search trees. Graphs. And the last page puts them all side by side, so you can choose between them.
- Sam That order seems deliberate.
- Priya It is. Each one builds on the last. Strings are arrays with a twist. Sets are maps without values. A heap is secretly a tree stored in an array. And graphs reuse lists, sets and queues.
- Sam How does each lesson work?
- Priya Same shape every time. What the structure is, with an everyday picture. How it sits in memory, animated. The operations and what they cost. The same code in Python, TypeScript and Java. Then the core operations as code players you can step through.
- Sam And those players talk now?
- Priya Press Play on any of them and I'll explain each step as the code runs. Then come easy LeetCode problems, traced the same way, a memory hook, the common mistakes and a quiz.
- Priya Your turn. Before you open lesson one: which structure do you think gives you the value at position five in one step?
- Priya An array. Finding box five is one calculation, whatever the length. That's where lesson one starts.
- Sam Where do I start?
- Priya Start here first, for Big-O and recursion. Then lesson one, arrays and lists.
1. Why structures first
One structure is used by many patterns. A hash map appears in Two Sum, sliding windows, prefix sums and grouping; a queue drives every breadth-first search. Meeting each structure half-explained inside each pattern is confusing, so the beginner path teaches all twelve first, in order, then starts the patterns with 21 · Array & String Basics.
2. The twelve lessons
01 · Arrays and lists
Numbered boxes: instant by index, slow in the middle.
02 · Strings and characters
Arrays of letters that can't change; build with a list.
03 · Hash maps
Key in, value out, no searching.
04 · Hash sets
In or out, instantly; duplicates vanish.
05 · Linked lists
Order kept by arrows; splice in O(1).
06 · Stacks
Last in, first out: undo, nesting, recursion.
07 · Queues and deques
First in, first out, and both ends with a deque.
08 · Heaps and priority queues
The smallest item, always on top.
09 · Trees and binary trees
A root and smaller trees below it; think recursively.
10 · Binary search trees and sorted maps
Smaller left, bigger right: halve the search each step.
11 · Graphs
Nodes and connections; store them as an adjacency list.
12 · Choosing a structure
Name the repeated question, pick the structure.
3. How each lesson works
- What it is, with an everyday picture, and how it sits in memory, animated.
- Operations and their costs, and the same code in Python, TypeScript and Java.
- Core operations, step by step: code players you can step through. Press Play and a voice explains each step as the code runs.
- Problems solved with it: easy LeetCode problems traced the same way, plus links to more practice on the pattern pages.
- A memory hook, common mistakes and a quiz to make it stick.
4. Where to start
New to coding interviews? Read Start here first (Big-O and recursion), then begin with 01 · Arrays and lists.