Only the last test case is showing W.A. Please help.
Optimal Game Strategy-I doubt1
@Rooopak_Sharma
You are employing a greedy technique in your code and taking the max of first and last term.
Also your code fails for such a testcase :
Input :
4
12 15 3 5
Expected Output :
20
Your Output :
18
Your code counts the two middle terms without counting any of the end terms for max sum. You cannot pick the number from the edges.
This problem has been discussed in detail in the last video of the Dynamic Programming section with its recursive function and detailed explanation.
Please refer to it.