Chalkboard XOR Game LeetCode solution in Java
1class Solution {2public boolean xorGame(int[] nums) {3int x = 0;4for (int i = 0; i < nums.length; i++) {5x ^= nums[i];6}7// if(x==0 || nums.length%2==0) // **This also works **8// return true;9// return false;10return (x == 0 || nums.length % 2 == 0);11}12}