Fill the table by hand
Warm-up · Trace the algorithm · about 5 min
The table holds the number of ways to climb to each step, moving 1 or 2 steps at a time. Work out the next cell before the trace writes it. Each cell is the sum of the two cells before it.
Example 1
Input:
{"n":7}
Output:
21
Constraints
- The table is for n = 7.
- Answer with whole numbers.
Learn the idea first: Tabulation: filling the table bottom-up, a visual lesson.
More Tabulation: filling the table bottom-up problems
- Fibonacci with a table Warm-up
- Order of filling Warm-up
- Climbing stairs Standard
- Ways to make a total from 1, 3 and 4 Standard
- Spot the bug: table size Standard
- Tribonacci with O(1) space Challenge