Climbing Stairs

How many distinct ways can you climb n stairs if you can take 1 or 2 steps at a time?

Time: O(n) | Space: O(n)

Controls

Range: 1 - 15

SlowMediumFast

Recurrence

dp[i] = dp[i-1] + dp[i-2]

Base: dp[0] = 1, dp[1] = 1

Staircase

0123456

DP Array

Press Start to begin the visualization
Configure the number of stairs and press Start to visualize the dynamic programming solution.