Optimal game strategy 1

i tried using normal recursion,one test case failed, i think im getting this question wrong, my logic is im first checking max of first and last and then in the remaining im checking max and then using recursion for n-2 elements, i dont know dp yet so how can i approach this question now


check my code above

@sktg99 Your logic will prove wrong for some test case. I suggest you to refer the video on Optimal game strategy which is there in the Dynamic Programming section.