My code did not pass 1 of the testcases. I am not getting any idea about the improvement which should be done to my code. Could you please suggest the modifications in my code.(link: https://ide.codingblocks.com/s/74875)
Optimal Game Strategy-I testacase not passed
dont consider the if-else statement over here.
you have to calculate both the optimal answers and then find the maximum out of the two.
F(i, j) represents the maximum value the user can collect from
i’th coin to j’th coin.
F(i, j) = Max(Vi + min(F(i+2, j), F(i+1, j-1) ),
Vj + min(F(i+1, j-1), F(i, j-2) ))
Base Cases
F(i, j) = Vi If j == i
F(i, j) = max(Vi, Vj) If j == i+1
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.