Stone pile game score
Your task
Two players play optimally with a row of stone piles of given positive values. On each turn a player takes the entire pile from either the left or right end. Each player tries to maximize their own total. Return the first player's score minus the second player's score under optimal play. Constraints: 1 <= n <= 500, 1 <= pile <= 1000.
Examples
stone_game_diff(piles: list[int]) -> intExample 1
Input
stone_game_diff([5, 3, 4, 5])Output
1