X DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
XOR of all elements
Basic Accuracy: 86.76% Submissions: 2807 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:

Input:
A = [2, 1, 5, 9]
Output:
13 14 10 6
Explanation:
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:â€‹

Input:
A = [2, 1]
Output:
1 2
Explanation:
At first position except first position
there is only one element = 1
At second position except second position
â€‹there is only one element = 2


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

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

We are replacing the old Disqus forum with the new Discussions section given below.

### Editorial

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

#### My Submissions:  