Optimal game strategy recursion challenge

it is passing sample test case but failing in all other test cases kindly tell the problem in the code

hello @shabadsingh in this question both the players play optimically so inorder to maximise your result you have to minimise your opponents result and then chose the maximum of both the results .
here for your reference i am giving you the correct code link …


I hope I have cleared your doubt …
Happy Learning !!

even my code is running for sample test case but not passing other test case can u tell the problem in my code
it would be more helpful

@shabadsingh This is what i am explainin to you that both the players play in an optical way that means both the players want to win so inorder to made piyush win we need to minimise nimits outcomes and you are not doing that .
thats why in some test cases your code is working fine and not in all .
i hope you have understood .

hey @shabadsingh as you are not replying i am marking this doubt as resolved.
on or off the chance if you feel you still have any doubt you can open this again .
Happy Learning !!

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.