Return value of the code

In the first two cases (base cases), how is the return value being determined?
Q.1. I mean, why have we returned 1 when n==0 and why return 0 when n<0.
Q.2. In the latter case, can we return -1 ( when n<0)

(Code snap attached for reference)

when n=0
means we have to find no of ways to reach at ground
which are 1 ways only

when n is negative then obviously there is no way to go in basement as basement doesn’t exits :slightly_smiling_face:

to “do nothing” there is also one way that is “do nothing”
:smile:

i hope this help
if you have any doubts feel free to ask
if doubt resolved don’t forgot to mark doubt as resolved

Yeah I had similar thoughts about the case when n<0. To do nothing, there is only one way, then the return value should be 1 just like when n==0, why return 0 in the second case?

for the case which doesn’t exist
there is no way to do it
because it doesn’t exist
n<0 doesn’t exist
there is no basement :smile:

Thank you :slight_smile:

in the bottom of any content(video or qeuestion) where you have asked this doubt
go there (in this case you have asked your doubt on a challenge “ ladders-problem-recursion”)

at bottom you find same as this

now at bottom-right you find a option of “mark as resolved”

There seems to be some glitch. I mark it as resolve and when I refresh the page, it is unresolved aagain. It’s not for the first time that it’s happened. Pls send the rating link, it helps me close the thread.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.