Tap here to switch tabs
Problem
Submissions

Problem: Stone Game IX

Stone Game IX has Alice and Bob remove values from an array. A player loses when the running sum becomes divisible by three, and Bob wins if every stone is removed safely. Return whether Alice wins.

Statement

Alice and Bob take turns playing a game, with Alice going first. You are given an integer array stones.

On each turn, the active player removes any stone from stones. A player loses immediately if the sum of the values of all removed stones so far is divisible by 33. If all stones are removed and the total sum of removed stones is never divisible by 33, Bob wins.

Assuming both players play optimally, return true if Alice wins, or false if Bob wins.

Constraints:

  • 1≤1 \leq stones.length ≤105\leq 10^5

  • 1≤1 \leq stones[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Stone Game IX

Stone Game IX has Alice and Bob remove values from an array. A player loses when the running sum becomes divisible by three, and Bob wins if every stone is removed safely. Return whether Alice wins.

Statement

Alice and Bob take turns playing a game, with Alice going first. You are given an integer array stones.

On each turn, the active player removes any stone from stones. A player loses immediately if the sum of the values of all removed stones so far is divisible by 33. If all stones are removed and the total sum of removed stones is never divisible by 33, Bob wins.

Assuming both players play optimally, return true if Alice wins, or false if Bob wins.

Constraints:

  • 1≤1 \leq stones.length ≤105\leq 10^5

  • 1≤1 \leq stones[i] ≤104\leq 10^4