Optimal game strategy -1 probklem

getting error

Do think about your approach, it’s wrong rn.
let me provide you a hint.
There need not be different cases for when i is even or odd.
Also, think like this
Two cases are possible whenever Piyush picks up a coin:

Whenever he picks from start, The opponent will pick a coin so as to defeat piyush, coz both play optimally,
Similarly, Whenever he picks from end, The opponent will pick a coin so as to defeat piyush, coz both play optimally,

So the ans is gonna be the maximum of the two cases.

This was the hint, now try and write the code, hope this helps!

i didn’t get u can u please explain it clearly