when n=0 , then we have 1 ways means when no one is going ???
Friends problems
yes bhaiya had told it in video
that if n=0 we have one way which is for the case when no one is going
but it will depend on question it’s there choice whether they include n=0 or say n>0
so check once when you submit the code
i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask
@asaurabh_26 i am trying to solve this problems simply using the fibnaaci concepts,
n == 0 return 0, n == 1 return 1, n == 2 return 2; and f(n-1) + f(n-2); so i am gettting the 3 ways when n=4, so it this right but when i dry the problems it actually 4 ways what to do???
Even i forget some of concepts of permutation and combination…
this recursive relation is not correct
correct one
f(n)= f(n-1) + (n-1)*f(n-2)
use this relation
not much concepts are needed in this question
as explained in video
a person has 2 options
-
it goes alone
f(n-1) -
it goes with friend so first he has to pick a friend
and to pick a friend he has n-1 option (he can pick any one from n-1 friends except him)
now n-2 persons left
so recursive call look like
(n-1)*f(n-2)
so finally we have
f(n)= f(n-1) + (n-1)*f(n-2)
@asaurabh_26 I got it. Can u explain when they is n == 0 then 1 ways in always exits The same things is apply in the ladder problem but i didn’t get it.
when no one is going to party there is 1 ways?? and also when we stand on the ground in ladder problems we have 1 ways to stand there?? how … Is i am misssing something
in case of friend problem
if n==0 then there is 1 way which is no one goes to party
in case of ladder problem
f(n) is no of ways to stand at nth ladder
if n==0 means we are at ground so there is one way to stand at ground hence return 1
@asaurabh_26 ya bro my doubt is same it means how this is possible when no is going to party then how its 1 ways actually there is 0 ways…
how is that 0 ways ??
no one is going
so it should be counted as 1 way
for a work you have two options
either you do it or not
you can’t say i have only one option
i can do this
if don’t do it then this is not a way
i hope this helps
don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask
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.