Climbing Stairs
Medium 40 XPDynamic ProgrammingMath
Commonly asked at Amazon, Google, Adobe
You are climbing a staircase with n steps. Each time you can climb 1 or 2 steps. In how many distinct ways can you reach the top?
- Input
- One integer n (1 ≤ n ≤ 80).
- Output
- Number of distinct ways.
Sample 1
Input
3
Output
3
Explanation: 1+1+1, 1+2, 2+1
Read input with input() (no prompt message) and print only the answer. Run tries the Input box; Submit checks all test cases.
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.The solution unlocks after 3 submissions.