Optimal game strategy-1

piyush picks 4, then nimit picks 1, then piyush can pick 3
so piyush will have value 7
then why in sample test case 6 given?

hi @dhairya16 , here both player will play optimally(Playing optimally means that both players will have insight into all possible next moves and will play in such a way to maximize their chance of winning without making a mistake.) so nimit will choose the coin that will result in less value left for piyush .

so coming to the giving example it means he has choice to choose between 1 and 3 so out of which he will choose the option which is good for him .
if he had chosen 1 then piyush would have 7 with him that’s why he choose 3 thus piyush getting 6 coins

In case of any doubt feel free to ask :slight_smile:
mark your doubt as resolved If you got the answer

How to solve using recursion?
Don’t know any approach

Hi @dhairya16, you can refer to this explaination i have provided the code with explanation

2 Likes