Tap here to switch tabs
Problem
Submissions

Problem: Chalkboard XOR Game

med
30 min
Try to solve the Chalkboard XOR Game problem.

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

med
30 min
Try to solve the Chalkboard XOR Game problem.

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}