dsa · easy
Climbing Stairs
GreyOrangeDynamic ProgrammingFoundation
You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
**Example 1:** `` Input: n = 2 Output: 2 ` **Example 2:** ` Input: n = 3 Output: 3 ``
Arguments
n— number of steps in the staircase
Constraints
1 <= n <= 45 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: 2 Expected: 2
Example 2
Input: 3 Expected: 3