  Showing: Handle Score
@Ibrahim Nash 5761
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4944
@saiujwal13083 4506
@sanjay05 3762
@marius_valentin_dragoi 3516
@sushant_a 3459
@verma_ji 3341
@KshamaGupta 3318
Sum of XOR of all pairs
Medium Accuracy: 35.3% Submissions: 17 Points: 4

Given an array of N integers, find the sum of xor of all pairs of numbers in the array.

Example 1:

â€‹Input : arr[ ] = {7, 3, 5}
Output : 12
Explanation:
All possible pairs and there Xor
Value: ( 3 ^ 5 = 6 ) + (7 ^ 3 = 4)
+ ( 7 ^ 5 = 2 ) =  6 + 4 + 2 = 12


â€‹Example 2:

Input : arr[ ] = {5, 9, 7, 6}
Output :  47



This is a function problem. The input is already taken care of by the driver code. You only need to complete the function sumXOR() that takes an array (arr), sizeOfArray (n), and returns the sum of xor of all pairs of numbers in the array. The driver code takes care of the printing.

Expected Time Complexity: O(N Log N).
Expected Auxiliary Space: O(1).

Constraints
2 ≤ N ≤ 10^5
1 ≤ A[i] ≤ 10^5

### Editorial

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

#### My Submissions:  