shlogg · Early preview
Md Ariful Haque @mah-shamim

Maximizing Stones In Stone Game II

Alice and Bob play optimally, return max stones Alice can get with dynamic programming and prefix sum calculation.

1140. Stone Game II
Difficulty: Medium
Topics: Array, Math, Dynamic Programming, Prefix Sum, Game Theory
Alice and Bob continue their games with piles of stones.  There are a number of piles arranged in a row, and each pile has a positive integer number of stones piles[i].  The objective of the game is to end with the most stones.
Alice and Bob take turns, with Alice starting first.  Initially,M = 1.
On each player's turn, that player can take all the stones in the first X remaining piles, where 1 <= X <= 2M.  Then, we set M = max(M, X).
The game continues until all the stones have been taken....