 Pots of Gold Game
##### Submissions: 4502   Accuracy: 33.26%   Difficulty: Medium   Marks: 4

Two player X and Y are playing a game in which there are pots of gold arranged in a  line, each containing some gold coins. They get alternating turns in which the player can pick a pot from one of the ends of the line. The winner is the player who has a higher number of coins at the end. The objective is to maximize the number of coins collected by X, assuming Y also plays optimally. You are required to complete the method maxCoins which returns an integer denoting the max coins X could get while playing the game. You may assume that X starts the game.

Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer denoting the no of gold pots. Then in the next line are N space separated values denoting the values (A[]) of gold coins in each pot.

Output:
For each test case in a new line print the maximum amount of money X can collect.

Constraints:
1<=T<=100
1<=N<=100
1<=A[]<=1000

Example(To be used only for expected output):
Input:

2
4
8 15 3 7
4
2 2 2 2

Output:
22
4

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harshit Sidhwa
Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.