In the following example, we are able to go from step 0 to step 3. I am assuming, this is because we can take 3 steps.
Fee: {1,2,5,2,1,2}
Output: 3
Explanation: Starting from index '0', we can reach the top through: 0->3->top
So, for the following example, why can’t it be just 0 -> top(index 3). Then cost will be just 2. why do we need to stop at index 1
Number of stairs (n): 4
Fee: {2,3,4,5}
Output: 5 Explanation: Starting from index '0', we can reach the top through: 0->1->top