Tap here to switch tabs
Problem
Submissions

Problem: Chalkboard XOR Game

Chalkboard XOR Game has Alice and Bob remove numbers from an array. A player loses when removal makes the remaining XOR zero. If zero at turn start, that player wins. Return Alice's outcome.

Statement

Alice and Bob play a game with an integer array nums written on a chalkboard. Alice takes the first turn.

On each turn, a player selects and removes one element from nums. If removing that element causes the bitwise XOR of all remaining numbers on the chalkboard to become 00, that player loses.

Additionally, if the bitwise XOR of all elements currently on the chalkboard is already 00 at the start of a player’s turn, that player wins immediately.

Assuming both players play optimally, return true if Alice wins the game, or false otherwise.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 0≤0 \leq nums[i] <216< 2^{16}

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Chalkboard XOR Game

Chalkboard XOR Game has Alice and Bob remove numbers from an array. A player loses when removal makes the remaining XOR zero. If zero at turn start, that player wins. Return Alice's outcome.

Statement

Alice and Bob play a game with an integer array nums written on a chalkboard. Alice takes the first turn.

On each turn, a player selects and removes one element from nums. If removing that element causes the bitwise XOR of all remaining numbers on the chalkboard to become 00, that player loses.

Additionally, if the bitwise XOR of all elements currently on the chalkboard is already 00 at the start of a player’s turn, that player wins immediately.

Assuming both players play optimally, return true if Alice wins the game, or false otherwise.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 0≤0 \leq nums[i] <216< 2^{16}