In LADDER PROBLEM ,the base case i.e. n=0 should be 0 because to reach n =0 is zero or on 0th stair should be zero but in this tutorial ,it is 1 why because we are not going to climb 0th stair we are on it previously…
Please explain briefly
hello @AMIT_KUMAR ,
this is done to make counting no of ways easy.
for example if we are stairs 1. then we say number of ways to reach this stairs is ways to reach 0 . so if we put 0 at n=0 then we need to add 1 on our own. but if we put 1 then we can simply do
ways[1]=ways[0]
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.