Recap: Name the State Behind Each Answer

Each exercise in this section had a slow answer that solved the same smaller problem over and over. The fast answer named that problem and solved it once. Here’s the state behind each one:

Exercise The question that unlocked it
Count Ways to Climb a Staircase How many ways reach the step I took my last move from?
Best Non-Adjacent Ad Slots What’s the best total so far if this slot stays empty, and if it shows an ad?
Fewest Stamps for Exact Postage If the last stamp has value v, how few stamps pay exactly the rest?
Count Paths Around Blocked Cells How many routes reach the cell above me and the cell to my left?

A quick self-check: think of the test that stayed red the longest for you. Which assumption in your code did it break? Interviewers often ask exactly that kind of question, and it’s a lot easier to answer once you’ve talked it through.

Want a second pair of eyes on your Dynamic Programming work?

From here on, the label comes off. Mixed Practice hands you problems and leaves the choice between searching and remembering to you, just like an interviewer would.

Become a Member to join the conversation.