Hi,
In solution #4, when the number of steps in the staircase is 2, the solution returns 1 instead of 2. Instead of the condition
if (n < 0)
return 0;
if (n <= 2)
return 1;
the code should be
if (n < 0)
return 0;
if (n <= 1)
return 1;
if (n == 2)
return 2;
And also I would appreciate if someone can please explain why all the given solutions are returning 1 when input is zero steps.
Type your question above this line.
Course: https://www.educative.io/collection/10370001/5347133077061632
Lesson: https://www.educative.io/collection/page/10370001/5347133077061632/5122140560949248