πŸ’‘ Optimal Game Strategy-I

one of the test cases is failing pls help
my code

hi pritika
no if-else comparison is required
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

1 Like