• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
December 19, 2023 |1.7K Views
PROBLEM OF THE DAY : 18/12/2023 | Game of XOR
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Jay Dalsaniya. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Bit Magic but also build up problem-solving skills.

In this problem, given an array A of size N. The value of an array is denoted by the bit-wise XOR of all elements it contains. Find the bit-wise XOR of the values of all subarrays of A.

Example :

Input: 
N = 3 
A = [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

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/game-of-xor1541/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-java-compiler/96296a8a-1eaa-4dcc-a7ca-6b1fa48682eb