/70. Climbing Stairs

70. Climbing Stairs

Easy
Probability53.9% acceptance

Given a positive integer total_steps, determine the number of distinct sequences of moves to reach the top of a staircase with total_steps steps, where each move consists of climbing either 1 or 2 steps. Return the total number of distinct sequences.

Example 1

Input: 4

Output: 5

Explanation: Possible sequences: [1,1,1,1], [1,1,2], [1,2,1], [2,1,1], [2,2]

Example 2

Input: 5

Output: 8

Explanation: Possible sequences: [1,1,1,1,1], [1,1,1,2], [1,1,2,1], [1,2,1,1], [2,1,1,1], [1,2,2], [2,1,2], [2,2,1]

Constraints

  • 1 <= total_steps <= 45
  • Input is a single integer representing the number of steps
Python (current runtime)

Case 1

Input: 6

Expected: 13

Case 2

Input: 7

Expected: 21

Case 3

Input: 8

Expected: 34