You are climbing a staircase. It takes n steps to reach the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
This is the classic introduction to Dynamic Programming. The key insight is that the number of ways to reach step n equals the sum of ways to reach step n-1 (then take 1 step) plus the ways to reach step n-2 (then take 2 steps).
Recurrence Relation: dp[i] = dp[i-1] + dp[i-2]
This follows the Fibonacci sequence pattern, making it an excellent first DP problem.
n = 22n = 33n = 451 <= n <= 45Click "Run" to execute your code against test cases
Socratic guidance - I'll ask questions, not give answers