My Code: https://ide.codingblocks.com/s/99768
3rd test case wrong answer in Optimal Game Strategy-I
hey @Harsh718, your code isn’t giving the max value for every case this case
4
8 15 3 7
your code’s output : 15
but the correct output should be : 22
okay. Can you tell where did my logic go wrong?
hey @Harsh718, this is the logic for question, Code according to this logic
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
1 Like
got it. I’ll try it again with this logic. Thanks
hey @Harsh718 , if your query is resolved. Please mark this doubt as resolved and rate me on the basis of your experience.
rating option will appear when to mark this doubt as resolved