346. Stone Game VII
Alice and Bob take turns playing a game, with **Alice starting first**. There are `n` stones arranged in a row. On each player's turn, they can **remove** either the leftmost stone or the rightmost stone from the row and receive points equal to the **sum of the remaining stones' values** in the row. The winner is the one with the higher score when there are no stones left to remove. Bob found that he will always lose this game (poor Bob, he always loses), so he decided to **minimize the score's difference**. Alice's goal is to **maximize the difference** in the score. Given an array of integers `stones` where `stones[i]` represents the value of the `i`th stone **from the left**, return *the **difference** in Alice and Bob's score if they both play **optimally***.
Examples
Input: [5,3,1,4,2]
Output: 6
Explanation: With both players optimal, Alice ends 6 points ahead of Bob.
Constraints
- n == stones.length
- 2 <= n <= 1000
- 1 <= stones[i] <= 1000
Run checks all cases above. Submit evaluates all test cases.