Optimal game strategy-1

This is the code that I submitted. 2 of the test cases show correct answer however 1 shows WA. Plz resolve this doubt ASAP or just provide the following test case as the testcases are blocked for the problem.

Hi @Satvik25
Your code is basically failing on test cases like :

4
8 14 4 6

your code will give output as 14 but its output should be 20 as piyush will first pick 6 and then nimit will pick 8 and then piyush will pick 14 making his maximum value as 20.

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.