[Python] O(n^2) Dynamic Programming
Python code:\npython\ndef stoneGameVII(self, A: List[int]) -> int:\n    n = len(A)\n    pref_s = A.copy()  # prefix sum\n    for i in range(1, n):\n        pref
## Python code:\n```python\ndef stoneGameVII(self, A: List[int]) -> int:\n    n = len(A)\n    pref_s = A.copy()  # prefix sum\n    for i in range(1, n):\n        pref_s[i] += pref_s[i-1]\n    pref_s.append(0)\n    dp = [0] * n\n    for step in range(2, n+1):\n        for i in range(n-1, step-2, -1):\n            dp[i] = max(pref_s[i-1] - pref_s[i-step] - dp[i-1],\n                            pref_s[i] - pref_s[i-step+1] - dp[i])\n    return dp[-1]\n```
['Dynamic Programming', 'Python']