Codele / Algorithms
Dynamic programming: fill a table
Solve the smallest cases first, write the answers in a table, and build up to the big question one square at a time.
- The table method solves the smallest cases first and builds up. Every square uses answers that already exist.
- Robot rule: routes to a square = routes to the square above + routes to the square on its left.
- The top row and left column have one route each, because there is only one way to reach them.
- A wall is a square with 0 routes. Squares next to it get fewer routes added.
- Remembering answers (last lesson) works from the top down. Filling a table works from the bottom up. Both skip repeated work.
Loading the playable lesson…