OPtimal game strategy

Help me for doing this question.

Hey @CODER_JATIN

logic:
Remember both A and B are equally smart and we want A to get maximum.
if coins are indexed from i to j and both have to choose one out of two ends.

case 1: if A chooses a[i], now opponent can choose either a[i+1] or a[j] whatever is maximum out of two. which means A will get Minimum in his next chance based on opponent choice.
case 1.a: if opponent choose a[i+1], player will chose either a[i+2] or or a[j]
case 1.b: if opponent choose a[j], player will chose either a[i+1] or or a[j-1]
So A will get minimum out of case 1.a and case 1.b…as opponent is equally smarter and choose such a coin which give him maximum but minimum to player A.

case 2: if A chooses a[j], now opponent can choose either a[i] or a[j-1] whatever is maximum out of two. which means A will get Minimum in his next chance based on opponent choice.
case 2.a: if opponent choose a[i], player will chose either a[i+1] or or a[j-1]
case 2.b: if opponent choose a[j-1], player will chose either a[i] or or a[j-2]
So A will get minimum out of case 2.a and case 2.a…as opponent is equally smarter and choose such a coin which give him maximum but minimum to player A.

This will give you a recursive case in which final answer is max(case1,case2)

Hey @CODER_JATIN
If u dont have any other doubt in this then please mark it as resolved :slight_smile:

Hey @CODER_JATIN
If u dont have any other doubt in this then please mark it as resolved :slight_smile:

bhaiya , please help me for building solution of tyhis problem/

Hey @CODER_JATIN
Check this for reference along with the explanation mentioned above : https://ide.codingblocks.com/s/285780?_ga=2.199645166.1350203873.1600106484-1795954092.1597348154

Hey @CODER_JATIN
If u dont have any other doubt in this then please mark it as resolved :slight_smile:

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.