Easy
Quiz
#70 Climbing Stairs
APPROACH
A staircase has n steps. On each move you may climb either 1 or 2 steps. Return the number of distinct ways to reach the top.
Example 1:
Input: n = 2
Output: 2
Explanation: There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
Example 2:
Input: n = 3
Output: 3
Explanation: There are three ways to climb to the top.
1. 1 step + 1 step + 1 step
2. 1 step + 2 steps
3. 2 steps + 1 step
1 of 4
1:00
What is the optimal approach for this problem?