Problem Description
You are given an array A of length N. Consider that the array is one indexed.
You need to find sum of ( A[i] & A[j] & (A[i] + A[j]) ) for all pairs (i,j) such that 1 <= i < j <= N.
2 <= N <= 2 x 105
1 <= A[i] <= 109
The only argument contains the integer array A.
Return the sum of A[i] & A[j] & (A[i] + A[j]) for all pairs. Since the answer can be large, return it modulo 109 + 7.
Input 1:
A : [8, 9]
Input 2:
A : [1, 3, 3]
Output 1:
0
Output 2:
2
Explanation 1:
There is only one pair - (8 & 9 & (8 + 9)) = 0
Explanation 2:
We have 3 pairs - (1, 3) = 1 & 3 & (1+3) = 0
(1, 3) = 1 & 3 & (1+3) = 0
(3, 3) = 3 & 3 & (3+3) = 2
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.