Given a staircase with a length of steps
, where you can take 1 or 2 steps at a time, find the number of distinct combinations to reach the top of the staircase from the bottom of the stairs.
steps: number
: An integerInput: steps = 1Output: 1Explanation: There is only one way i.e take 1-step
Input: steps = 2Output: 2Explanation: There are two ways, either take two 1-step or take one 2-step
Input: steps = 3Output: 3Explanation: There are three ways: 1-step three times, 1-step then 2-step, 2-step then 1-step
steps
<= 45Given a staircase with a length of steps
, where you can take 1 or 2 steps at a time, find the number of distinct combinations to reach the top of the staircase from the bottom of the stairs.
steps: number
: An integerInput: steps = 1Output: 1Explanation: There is only one way i.e take 1-step
Input: steps = 2Output: 2Explanation: There are two ways, either take two 1-step or take one 2-step
Input: steps = 3Output: 3Explanation: There are three ways: 1-step three times, 1-step then 2-step, 2-step then 1-step
steps
<= 45console.log()
statements will appear here.