Optimal Strategy For A Game

easy
1. You are given N coins as an integer array, size of array is even
 2. You are playing against an opponent where both of you get turns alternatingly
 3. In each turn a player removes either last of the first element from the array permanently and adds that coin value to his pile
 4. You need to find the maximum amount of money you can win if you go first
 5. Input and output is handled for you
 6. It is a functional problem ,please do not modify main()

Input Format

Input is handled for you

Output Format

Output is handled for you

Constraints

2 <= N <= 100
 1<= A[i]<=10^6

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
4
8 15 3 7
Output
22
Previous
Word Break
Next
Longest Bitonic Subsequence

Related Questions