Counts Zeros Xor Pairs
Submissions: 3315   Accuracy:

54.63%

  Difficulty: Easy   Marks: 2

Given an array A[] of size N. Find the number of pairs (i, j) such that  A_i XOR  A_j = 0, and 1 <= i < j <= N.

Input:
The first line of the input contains a single integer T denoting the number of test cases. The first line of each test case contains N. followed by N separate integers. 

Output:
For each test case, output a single integer i.e counts of Zeros Xors Pairs

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

Example:
Input :
2
5
1 3 4 1 4

3
2 2 2

Output :

2
3

Explanation :

Test Case 1: Index( 0, 3 ) and (2 , 4 ) are only pairs whose xors is zero so count is 2.

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

Contributor: Nishant Singh
Author: Nishant_Singh


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.