Skip to content

Practice Stone Game VI

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1686
LeetCode Problem

Stone Game VI

Problem Statement

Alice and Bob alternately choose one remaining stone, with Alice first. Choosing stone i awards aliceValues[i] to Alice or bobValues[i] to Bob, depending on who chose it. Both know both value arrays and play optimally. After all stones are chosen, return 1 if Alice scores more, -1 if Bob scores more, or 0 for a tie.

Source: Stone Game VI on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
aliceValues = [1,3], bobValues = [2,1]
Output
1

# Example 2

Input
aliceValues = [1,2], bobValues = [3,1]
Output
0

# Example 3

Input
aliceValues = [2,4,3], bobValues = [1,6,7]
Output
-1

Constraints

n == aliceValues.length == bobValues.length
1 <= n <= 10^5
1 <= aliceValues[i], bobValues[i] <= 100

Related LeetCode Problems

Practice more problems similar to Stone Game VI.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.