Calvin’s Game few test cases are failing

Hello,

A few of my test cases are failing could you please suggest what I am missing. This is my code.

Hello - Its being a long time and i didn’t got any reply on this doubt

@S18APP-OL0003
for backward fill, dpB[i] represents the max cost if it goes from i to 0.
so your dpB[i] should be max(dpB[i-2]+arr[i-2], dpB[i-1]+arr[i-1])

also since you are taking zero-based indexing then do k=k-1, since it is 1-based indexed.

Also match your array initialization with my code https://ide.codingblocks.com/s/251433
It is in c++ but the logic is same, you can easily read it.

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.