why is this code failing 3rd test case ?
Optimal game strategy 3rd test case failing
you need to optimally calculate both the answers and then the final answer would be the maximum 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