Optimal Game Strategy-1

The code is for Optimal game strategy 1. its passing for testcase 2 & 3 but not 1. Please tell me where its getting wrong?

you are prefering the greater elements always.
don’t try greedy approach here.

like if we have
1 2 8 4
you will choose 4
and other will get 8, and he will win

but if u choose 1
then other can only choose from 2 or 4 and then u can get 8.

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.