Optimal Strategy for a Game

You are given an array arr of positive integers. Two players take turns picking numbers, with Player 1 going first.

On each turn, a player picks either the first or the last element of the remaining array. The player adds the picked number to their score. The game ends when the array is empty.

Assuming both players play optimally to maximize their own score, return the maximum score Player 1 can achieve.

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

Optimal Strategy for a Game

You are given an array `arr` of positive integers. Two players take turns picking numbers, with Player 1 going first.