Game Of Xor | Geeks for geeks
Game of XOR
Difficulty: MediumAccuracy: 50.77%Submissions: 40K+Points: 4
You are given an integer array arr[]. The value of a subarray is defined as the bitwise XOR of all elements in that subarray.
Your task is to compute the bitwise XOR of the values of all possible subarrays of arr[].
Examples:
Input: arr[] = [1, 2, 3]
Output: 2
Explanation:
xor[1] = 1
xor[1, 2] = 3
xor[2, 3] = 1
xor[1, 2, 3] = 0
xor[2] = 2
xor[3] = 3
Result : 1 ^ 3 ^ 1 ^ 0 ^ 2 ^ 3 = 2
Input: arr[] = [1, 2]
Output: 0
Explanation:
xor[1] = 1
xor[1, 2] = 3
xor[2] = 2
Result : 1 ^ 3 ^ 2 = 0Constraints:
1 ≤ arr.size() ≤ 105
0 ≤ arr[i] ≤ 109
Comments
Post a Comment
Hi there,
I am ${NAME},
${Subject}
I would like to thank/suggest regarding this post.
${Description}
Please enter your description here[if willing to 😉].