Dodomeki
Sign in

38. Climbing Stairs

Easy

You are given a staircase with n steps. On each move, you may climb either 1 or 2 steps. How many different ways are there to reach the top?

Example 1
Input: n = 4
Output: 5
Explanation: The possible step sequences are five.
Example 2
Input: n = 5
Output: 8
Constraints
  • 1 <= n <= 45
Dynamic programming
Caso 1
n =
4
Expected =
5
Caso 2
n =
5
Expected =
8

Run checks these 2 cases. Submit runs all 7, including hidden ones.