Optimal Game Strategy 1

Sir, can you please help he find out what could be the error in my code ?
Code ide : https://ide.codingblocks.com/s/188272

line no 16
it should be the following statment:
int b = arr[j] + Math.min(solve(i,j-2),solve(i+1,j-1));
it was incorrectly written as
int b = arr[j] + Math.min(solve(i,j-1),solve(i+1,j-1));

Still I can’t pass test case 1

comment out the following line of code
// if(i==j-1)
// return Math.max(arr[i],arr[j-1]);

It worked. But why did we commented that part ?

u see u are compariing if i == j-1 and then returning max of a[i] a[j-1] wont they be the same thing,
it is not the base condition try to dry run u`ll understand better

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.