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) ))
As user wants to maximise the number of coins.
F(i, j) = Vi If j == i
F(i, j) = max(Vi, Vj) If j == i + 1
Read more here: https://stackoverflow.com/questions/66385858/what-will-be-time-and-complexity-of-given-code
This content was originally published by Rohit Kashyap at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.