Spot the bug: table size
Standard · Find the bug · about 6 min
This function should return the number of ways to climb n steps with moves of 1 or 2, but it crashes or returns the wrong value. Click the line with the bug, then fix it.
Example 1
Input:
[3]
Output:
3
The buggy code reads past the end of the table.
Constraints
- 1 ≤ n ≤ 45
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
- Fill the table by hand Warm-up
- Order of filling Warm-up
- Climbing stairs Standard
- Ways to make a total from 1, 3 and 4 Standard
- Tribonacci with O(1) space Challenge