Stone Game VII | Python | Self Explanatory Code
\nclass Solution:\n    def dpFn(self, stones, total, left, right, dp):\n        if dp[left][right] is None:\n            if right == left:\n                dp[l
```\nclass Solution:\n    def dpFn(self, stones, total, left, right, dp):\n        if dp[left][right] is None:\n            if right == left:\n                dp[left][right] = 0\n            if right - left == 1:\n                dp[left][right] = max(stones[left], stones[right])\n            if left < right:\n                leftRemovedAliceScore = total - stones[left]\n                bobScoreAfterAliceRemovedLeft = self.dpFn(stones, leftRemovedAliceScore, left + 1, right, dp)\n                rightRemovedAliceScore = total - stones[right]\n                bobScoreAfterAliceRemovedRight = self.dpFn(stones, rightRemovedAliceScore, left, right - 1, dp)\n                dp[left][right] = max(leftRemovedAliceScore - bobScoreAfterAliceRemovedLeft,\n                                      rightRemovedAliceScore - bobScoreAfterAliceRemovedRight)\n        return dp[left][right]\n\n    def stoneGameVII(self, stones: List[int]) -> int:\n        n = len(stones)\n        dp = [[None] * n for _ in range(n)]\n        return self.dpFn(stones, sum(stones), 0, len(stones) - 1, dp)\n\n```
[]