Practice Stone Game V
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue. In each round of the game, Alice divides the row into two non-empty rows (i.e. left row and right row), then Bob calculates the value of each row which is the sum of the values of all the stones in this row. Bob throws away the row which has the maximum value, and Alice's score increases by the value of the remaining row. If the value of the two rows are equal, Bob lets Alice decide which row will be thrown away. The next round starts with the remaining row. The game ends when there is only one stone remaining. Alice's score is initially zero. Return the maximum score that Alice can obtain.
Source: Stone Game V on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
stoneValue = [6,2,3,4,5,5]
18
# Example 2
stoneValue = [7,7,7,7,7,7,7]
28
# Example 3
stoneValue = [4]
0
Constraints
Related LeetCode Problems
Practice more problems similar to Stone Game V.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.