You are viewing a single comment's thread. Return to all comments →
Interesting problem.. if (arr.length %2 == 0 ){ return 0; } int result = 0; for (int i =0; i< arr.length; i++){ if(i%2 == 0 ){ result ^= arr[i]; }
If you generate the all possible sub arrays..It's easy to understand the logic.
Seems like cookies are disabled on this browser, please enable them to open this website
Sansa and XOR
You are viewing a single comment's thread. Return to all comments →
Interesting problem.. if (arr.length %2 == 0 ){ return 0; } int result = 0; for (int i =0; i< arr.length; i++){ if(i%2 == 0 ){ result ^= arr[i]; }
If you generate the all possible sub arrays..It's easy to understand the logic.