Can i get the hint of the problem

can i get the hint of the problem

post question also, so that i can help you.

Piyush and Nimit are playing a coin game. They are given n coins with values x1, x2 …. xn where ‘n’ is always even. They take alternate terms. In each turn, a player picks either the first coin or the last coin from the row and removes it from the row. The value of coin is received by that player. Determine the maximum value that Piyush can win with if he moves first. Both the players play optimally.

Input Format

First line contains the number of coins ‘n’.
Second line contains n space separated integers where ith index denotes the value of ith coin.

Constraints

1 < N <= 30 , N is always even
0 <= Ai <= 1000000

Output Format

Print a single line with the maximum possible value that Piyush can win with.

Sample Input

4

1 2 3 4

Sample Output

6

I f you only want hint then :

you can open another doubt, if you want code too.

thanks.

i cant think of the way to calc different marks for piyush and nitin

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.

and espically i am not able to do it using recursion

you can use two different variable to store their coins values

do you want code for this problem

yes i want the code to this problem

yes but like loop is running every time how can we get to no we have to add it for Piyush or Nitin

I would recommend you to first try it, then see the code. as it is one of the basic problems. You can open aother doubt tommorow if you can’t solve it. And if you are not able to solve this using recursion, you can also try it using loop.

Do you still want the code??

no i will try it on my own thank you i will ask if i need one

1 Like

you can mark this as resolved for now and please give your feedback above.
thanks.

i am trying to do it using recursion because it is in recursion problems

1 Like

can i tried but its failing - https://ide.codingblocks.com/s/309534