Game of Maximization

Two players play a game with an array of integers arranged in a line. On each turn, a player picks one integer from either the left end or the right end of the remaining array. Both players play optimally to maximize their own total sum. Return the maximum sum the first player can achieve.

Examples
Input: [5,3,7,10]
Output: 15
Hints

Game of Maximization

Two players play a game with an array of integers arranged in a line. On each turn, a player picks one integer from either the left end or the right end of the remaining array. Both players play optimally to maximize their own total sum. Return the maximum sum the first player can achieve.