Optimal game strategy

In this question how come the output is 6?

“Piyush will pick the coin 4. Then Nimit can pick either 1 or 3. In both the cases Piyush picks coin 2 and wins with a total of 6.” This is the explanation given for the sample test case but if Nimit picks 1 then Piyush can have maximum value of 7 right? But it is given in both cases it will be 6. I don’t understand.

Hey @div_yanshu07 as in the question it’s clearly motioned that Both the players play optimally.
Due to which NIMIT will also try to maximize it’s profit. So when he will get a condition of picking either 1 or 3, he will definitely pick 3 to maximise his profit and rest over choices will be left for piyush.

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.