There are several stones arranged in a row, where each stone has an associated value given in the array stoneValue.
Alice and Bob play a game with these stones. In each turn, Alice divides the current row of stones into two non empty parts: a left row and a right row. Bob then evaluates the sum of values of stones in each part:
If the sum of the left row is less than the sum of the right row, Bob discards the right row. Alice earns points equal to the sum of the left row, and the game continues with the left row.
If the sum of the right row is less than the sum of the left row, Bob discards the left row. Alice earns points equal to the sum of the right row, and the game continues with the right row.
If the sum of both rows is equal, Bob lets Alice decide which row to discard. Alice earns points equal to the sum of the chosen remaining row, and the game continues with that row.
The game concludes when only
Return the maximum total score Alice can achieve.
Constraints:
stoneValue.length
stoneValue[i]
There are several stones arranged in a row, where each stone has an associated value given in the array stoneValue.
Alice and Bob play a game with these stones. In each turn, Alice divides the current row of stones into two non empty parts: a left row and a right row. Bob then evaluates the sum of values of stones in each part:
If the sum of the left row is less than the sum of the right row, Bob discards the right row. Alice earns points equal to the sum of the left row, and the game continues with the left row.
If the sum of the right row is less than the sum of the left row, Bob discards the left row. Alice earns points equal to the sum of the right row, and the game continues with the right row.
If the sum of both rows is equal, Bob lets Alice decide which row to discard. Alice earns points equal to the sum of the chosen remaining row, and the game continues with that row.
The game concludes when only
Return the maximum total score Alice can achieve.
Constraints:
stoneValue.length
stoneValue[i]