Why is my Memoization technique giving the Wrong Answer for 3 test cases?
Solution-https://ide.codingblocks.com/s/72503
Cell Mitosis Problem
Hi
approach for this question is little different
approach will be like
if i is even
dp[i]= min(dp[i/2]+x,dp[i-1]+y} ;
if i is odd
dp[i]=min(dp[i-1]+y,dp[i+1/2]+x+z} ;
for more explanation have a look at video, it’s in the course ( advance dp cell mitosis) , if you have doubt in approach please do post.
Hit like if you get it
Cheers
Sir, I have seen that video and submitted the solution but when considering the various test cases
(manually) for the video dp solution and my memoization solution, i got only a few test cases wrong. why?
Their can be many more cases that will give wrong on your approach, and few ho ya many approach is wrong if produces wrong test cases.
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.
@tusharsk Bhaiya I think It goes into infinite function call.
eg-> if n=5;
as 5 is odd
fun(5+1/2);(This function will be called again again.)
and other thing->
dp[i]=min(dp[i-1]+y,dp[i+1/2]+x+z} ;
Bhaiya how you write ‘+z’ in this line.
Bhaiya Thanks in advance.
@monikabhasin.sd17 for dp[odd]=Math.min(dp[odd-1]+y,dp[(odd/2)+1]+x+z);
if i =5 then dp[(5/2)+1 ], it will be dp[3], now 3*2-1=5, we are double the cell and ,dec. by 1, and dec cpst is z, thats why we will add z and x add for doubling the cells.
Thanks