Climbing Stairs
EasyDynamic Programming
You are climbing a staircase with n steps. Each time you can climb 1 or 2 steps. How many distinct ways can you reach the top?
Example:
Input: n = 3
Output: 3
Explanation: Three ways — 1+1+1, 1+2, 2+1
Constraints:
- •
1 <= n <= 45
Climbing Stairs
EasyDynamic Programming
You are climbing a staircase with n steps. Each time you can climb 1 or 2 steps. How many distinct ways can you reach the top?
Example:
Input: n = 3
Output: 3
Explanation: Three ways — 1+1+1, 1+2, 2+1
Constraints:
- •
1 <= n <= 45
Press Run or Ctrl+Enter to execute