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?
Optimal game strategy-1
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 
mark your doubt as resolved If you got the answer
How to solve using recursion?
Don’t know any approach