Optimal Game Strategy-I https://ide.codingblocks.com/s/169106

Run error in all the test cases

greedy approach will not work here
just check ur code for : 1 2 8 4

ur code will give:2+4
but o/p should be : 1+8

Ohh alright… But how do i do that??

the simplest approach is that
you calculate the sum of coins which are on even index and odd index separately.
if odd index coin sum is greater then u should choose all the odd index coins

u can mange to choose either odd or even positioned index coins.

but this is logical approach
u can just print sum either the even or odd placed coin whose sum is greater.

but
the proper approach is very interesting
first u try search it.
this is very standard prblm , u can find it very easily.

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.