XOR of all elements
Basic Accuracy: 57.9% Submissions: 76 Points: 1

Given a list A having N positive elements. The task to create another list such as ith element is XOR of all elements of  A except A[i].

Example 1:

A = [2, 1, 5, 9]
13 14 10 6
At first position 1^5^9 = 13
At second position 2^5^9 = 14
At third position 2^1^9 = 10
At last position 2^1^5 = 6

Example 2:​

A = [2, 1]
1 2
At first position except first position 
there is only one element = 1
At second position except second position
​there is only one element = 2

Your Task:  
You don't need to read input or print anything. Your task is to complete the function getXor() which takes a list A and an integer N which is the size of the list A and return the modified list.

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1), Where N is the size of the input array

1<= N <=10000
1<= A[i] <=100000

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Output Window