Your concept feed
11 ideas
A small tour through the main ideas
A small step before this topic
Let’s picture it Let’s start with three stops.
Home. Then the park. Then the café. Just a few things in a row.
One little change Point to the middle one.
The park is second. In Python, its position is 1, because counting starts at 0.
Now it has a name That’s a list.
A list keeps things in order. An index is just a position in that list.
No pressure. Just try it.Which place is at position 0?
1 / 4 A small step before this topic
Let’s picture it Same door. One small difference.
You have a key. Your friend doesn’t. The door is the same, but your next move isn’t.
One little change Remember the key.
If we only write down “at the door,” we lose something important.
Now it has a name That little note is a state.
A state remembers what we need to continue. Here: where we are, and whether we have the key.
No pressure. Just try it.Is “at the door” enough to decide if we can enter?
1 / 4 A small step before this topic
Let’s picture it Open a box.
There’s a smaller box inside. We already know how to open a box.
One little change Do the same small job again.
Open the smaller box. Keep going until there isn’t another box inside.
Now it has a name That’s the idea of recursion.
A function asks itself to handle a smaller case. The empty box is our stopping point: the base case.
No pressure. Just try it.What if every box contains another box forever?
1 / 4 A small step before this topic
Let’s picture it Try every pair first.
In a sorted row [1,2,4,7], seek a pair totaling 9. Checking every pair repeats work.
One little change Look at both ends.
1 + 7 is too small. Moving the right pointer left only makes the sum smaller, so move the left pointer right.
Now it has a name Discard with a reason.
too small → left
too large → right
equal ✓
Now 2 + 7 = 9. Each move removes an entire family of impossible pairs, so both pointers move only forward overall.
No pressure. Just try it.When the sum is too small, which pointer can safely move?
1 / 4 A small step before this topic
Let’s picture it Count a tiny family of dots.
One parent has two children. Each child says, “There’s one of me.”
One little change Let the answers travel up.
The parent adds the two answers, then counts itself: 1 + 1 + 1.
Now it has a name That works for bigger trees too.
my answer
left answer
right answer
Ask each child about its little tree. Combine the answers. You don’t need to hold the whole tree in your head.
No pressure. Just try it.Do we also count the parent itself?
1 / 4 A small step before this topic
Let’s picture it Come back to our little map.
Home, park, café. Each place is a dot; each allowed walk is a link.
One little change A dot can also mean a situation.
“At park with a key” may allow a move that “at park without a key” cannot.
Now it has a name Choose dots that tell the whole story.
situation
legal move
new situation
A graph organizes possible moves. Sometimes places are enough. Sometimes a place plus a small extra fact is needed.
No pressure. Just try it.Must graph nodes always represent physical places?
1 / 4 A small step before this topic
Let’s picture it Try a snack combination.
Pick apple first. See what can go with it. We’re exploring, not committing forever.
One little change Put it back and try again.
After exploring the apple choices, undo that pick. Now start with banana.
Now it has a name That’s backtracking.
Choose, explore, undo. Undoing keeps the next attempt from accidentally inheriting the last attempt’s choices.
No pressure. Just try it.Before a sibling attempt, what happens to path-only choices?
1 / 4 A small step before this topic
Let’s picture it Car and cat start the same way.
Write c, then a, just once. Split where the words become different.
One little change A prefix isn’t always a word.
If we only stored cart, reaching c-a-r is not enough to say car was stored too.
Now it has a name Mark where each word ends.
This shared-prefix tree is a trie. The word-end mark tells a whole word apart from just its beginning.
No pressure. Just try it.Only cart is stored. Does car count as a stored word?
1 / 4 A small step before this topic
Let’s picture it We’ve answered this before.
route A
3 stairs left
route B
Two routes leave us with three stairs left. We may climb one or two at a time.
One little change Save these three little routes.
The routes are 1+1+1, 1+2, and 2+1. Count them once; both arrivals can reuse the answer.
Now it has a name That sharing is the heart of DP.
same question
reuse answer
Dynamic programming saves answers to smaller questions. Share only when the remaining question really is the same.
No pressure. Just try it.One route has a key left and the other doesn’t. Always the same remaining question?
1 / 4 A small step before this topic
Let’s picture it Take the biggest snack first?
Values are 4, 5, 4, and neighbors cannot both be taken. The biggest is 5.
One little change But the two 4s make 8.
The tempting first choice blocked a better total. Looking best now wasn’t enough.
Now it has a name Try to break a greedy rule.
Greedy means committing to a local choice. Before trusting it, ask what that choice might block later.
No pressure. Just try it.Does one failing example disprove “always take the biggest” here?
1 / 4 A small step before this topic
Let’s picture it You don’t have to guess the name.
Start smaller: what do I need to remember, and what can I do next?
One little change Then look for one useful clue.
layers
saved answers
safe choices
Equal-cost moves suggest BFS. Repeated remaining questions suggest DP. A safe local choice suggests greedy.
Now it has a name Check the clue before choosing.
Change one rule and ask if the explanation still works. An algorithm’s name comes after the reason, not before it.
No pressure. Just try it.Should a familiar keyword replace checking the problem’s rules?
1 / 4 Keep a connection for later.
Tap the bookmark on any post to find it here.