Optimal game strategy -1(recursion)


i am getting two incorrect testcases.
Please tell me the problem?

@aditi2512201012019,
In your code, you are just picking up the rightmost coin always. How does that ensure optimal play?
Are you sure you understand the problem? Make sure you know how to solve the Wine dp problem before trying this.

https://ide.codingblocks.com/s/220754 , its still showing error now.

@aditi2512201012019,
Because you are greedily choosing between a[I] and a[j], which is not correct. I repeat, have you done the Wine DP problem…??I don’t think you understand, why greedy would fail in these type of problems.

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.