Friends pairing problem


why is this code giving wrong output for 84…on geeksforgeek
plz correct the code …i want to solve this question using topdown only…
what is wrong in my recurrence relation???

your approach is not correct if you want to do it using topdown see this

why cant we use the base condition as
if(n==2) {
dp[n]=n;
return dp[n];
}

tell me why f[2]=2 and not 3 .
suppose 2 person x and y …x goes alone or y goes alone or they they go together
reply at the earliest…

right
suppose 2 person x and y …
x goes alone and y goes alone
or they they go together

these are only two ways

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.