Practice Stone Game IX
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
Alice and Bob continue their games with stones. There is a row of n stones, and each stone has an associated value. You are given an integer array stones, where stones[i] is the value of the ith stone. Alice and Bob take turns, with Alice starting first. On each turn, the player may remove any stone from stones. The player who removes a stone loses if the sum of the values of all removed stones is divisible by 3. Bob will win automatically if there are no remaining stones (even if it is Alice's turn). Assuming both players play optimally, return true if Alice wins and false if Bob wins.
Source: Stone Game IX on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
stones = [2,1]
true
# Example 2
stones = [2]
false
# Example 3
stones = [5,1,2,4,3]
false
Constraints
Related LeetCode Problems
Practice more problems similar to Stone Game IX.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.