Back to DSA
Climbing Stairs
easyA staircase has n steps. On each move you may ascend either one step or two steps. Calculate how many distinct sequences of moves will bring you from the ground to the top.
Examples
Example 1:
Input:
n = 4Output:
5Explanation: The five ways are: 1+1+1+1, 1+1+2, 1+2+1, 2+1+1, 2+2.
Example 2:
Input:
n = 5Output:
8Explanation: There are eight distinct sequences of 1-step and 2-step moves.
Hints
1234567