Optimal Game 1 problem

Last test case not working

In above one I was applying wrong concept…I was finding the sum for the odd position and the sum at the even position…
still four test case was correct.

But now I understand that I have to optimally move… starting person has to select such postion number so that he may get max value…while the other have to do the same thing . i.e to minimize the other profit…

I rewrote the code according to the above concept…still the same issue last test case giving wrong answer…
here is the updated code…

Since this type of code comes under DP but it’s given under recursion so I have solved using that only …

please review both my code and make necessary chances so that my last test case give correct answer

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.