2/40
Part 1 of 7 · Four thingsLearn

Four things to write down before any code

The coin-change lesson filled a table with one index, the amount. Most dynamic programs in interviews need more than one number to say where you are:

  • a position in a list, and how many deletions you've used
  • a spot in each of two strings
  • a junction on a trail, and how many expert stretches you've ridden to get there

This lesson is about those states with more than one part, and the tables they fill.

Collect points from the top-left to the bottom-right
grid
314115926535

Start at the green 3 and end at the green 5, moving only right or down.

You start at the top-left cell and move only right or down. You collect the points of every cell you pass. What's the most you can collect by the bottom-right cell?

Predict

Moving only right or down, what's the most you can collect by the bottom-right cell?

Pick an answer above to see the rest