My code is showing wrong answer
Optimal Game Strategy-I
Basically in your code you are applying greedy approach which means selecting that coin from end or begin which is of maximum value but that is not always true in this qstn.Take example of 8,15,3,7
According to your logic you first select max of 8 or 7 and than other player chooses 15 and you get 8+7=15 but ans for this eg is 15+7=22,so your logic fails here.
@vanshika1205 Basically in your code you are applying greedy approach which means selecting that coin from end or begin which is of maximum value but that is not always true in this qstn.Take example of 8,15,3,7
According to your logic you first select max of 8 or 7 and than other player chooses 15 and you get 8+7=15 but ans for this eg is 15+7=22,so your logic fails here.
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.