Algorithm · Medium
You have a staircase with n steps leading from the ground to the top. You can advance by taking a step of size 1 or size 2. Count the total number of distinct sequences of moves that bring you exactly to the top step. Two sequences are considered different if there is any position where the step sizes differ. For instance, stepping 1 then 2 is not the same as stepping 2 then 1. Examples Example 1 Explanation: The valid sequences are 1+1+1+1, 1+1+2, 1+2+1, 2+1+1, and 2+2.…
Checking your access…