AlgoFrames

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