Alice and Bob are playing a game with piles of stones arranged in a row, where the number of stones in each pile is given by the integer array piles.
Alice begins the game. At the start, the value of M is set to
On each turn, a player can take all the stones from the first X remaining piles, where M is updated to
The game continues until all piles have been taken. Assuming both Alice and Bob play optimally to maximize their total number of stones, return the maximum number of stones Alice can obtain.
Constraints:
piles.length
piles[i]
Alice and Bob are playing a game with piles of stones arranged in a row, where the number of stones in each pile is given by the integer array piles.
Alice begins the game. At the start, the value of M is set to
On each turn, a player can take all the stones from the first X remaining piles, where M is updated to
The game continues until all piles have been taken. Assuming both Alice and Bob play optimally to maximize their total number of stones, return the maximum number of stones Alice can obtain.
Constraints:
piles.length
piles[i]