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.
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.
For each test case in a new line print the maximum amount of money X can collect.
Example(To be used only for expected output):
8 15 3 7
2 2 2 2
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.