I have applied brute force algorithm using recursion. All test cases except test case 0 is being passed.
Please tell which test case is my code failing, for I have tried multiple test cases
Wrong test case 0
hello @gaganwalia212

these steps are wrong. since nimit is also playing optimally.
he will pick that coin which will give him overall maximum ( picking current maximum will not give overall maximum always).
this should be ur recurrence relation
solve(i,j)= max ( a[i] + min(solve(i+1,j-1) ,solve(i+2,j) , a[j] + min(solve(i,j-2) ,solve(i+1,j-1) );
1 Like
ok sir i have realized my mistake… Thank You so much
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.