Card Match Game

Two players play a game with n cards arranged in a row. Each card has a positive integer value written on it. On each turn, a player must take either the leftmost or the rightmost remaining card, adding its value to their total score.

Both players play optimally to maximize their own total score. Given the array of card values, compute the maximum total score the first player can achieve.

Examples
Input: [4,6,2,3]
Output: 9
Hints

Card Match Game

Two players play a game with n cards arranged in a row. Each card has a positive integer value written on it. On each turn, a player must take either the leftmost or the rightmost remaining card, adding its value to their total score.