1872. Stone Game VIII

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1872

class Solution:
    def stoneGameVIII(self, stones: List[int]) -> int:
        s = list(accumulate(stones))
        f = s[-1]
        for i in range(len(s) - 2, 0, -1):
            f = max(f, s[i] - f)
        return f