LeetCode 70: Climbing Stairs, Deriving 1D DP from dp[i]

Problem Input and Output Input: an integer n Meaning: climb to the top of the n-step staircase Each move can climb 1 or 2 steps Output: return the number of distinct ways to reach the top Constraints: 1 <= n <= 45 Examples Input: n = 2 Output: 2 Explanation: 1+1, 2 Input: n = 3 Output: 3 Explanation: 1+1+1, 1+2, 2+1 This article uses Python only and derives the final solution step by step from the meaning of dp[i]. ...

May 3, 2026 · 6 min · map[name:Jeanphilo]