XOR of all elements
Submissions: 1396   Accuracy:

61.49%

  Difficulty: Basic   Marks: 1

Given an array A[] having n positive elements. The task to create another array B[] such as B[i] is XOR of all elements of array A[] except A[i].

Examples:

Input : A[] = {2, 1, 5, 9}
Output : B[] = {13, 14, 10, 6}

Input : A[] = {2, 1, 3, 6}
Output : B[] = {4, 7, 5, 0}


Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer N denoting the size of the array. Then in the next line are N space separated values of the array (B[]).

Output:
For each test case in a new line print the space separated values of the new array (B[]). 

Constraints:
1<=T<=100
1<=N<=100
1<=A[]<=100

Example:
2
4
2 1 5 9
4
2 1 3 6
Output:
13 14 10 6
4 7 5 0

** For More Input/Output Examples Use 'Expected Output' option **

Author: Shubham Joshi 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.