Zero Xor

5

4 votes
Algorithms, Arrays, Binary Search, Medium, Meet in the Middle, Searching
Problem

A Zero Xor Subset is a non-empty subset having Xor of all the elements in it equal to 0.
Now you are given an array of N numbers.
You have to count the number of different Zero Xor Subsets of this array.

Input:
First line contains a number N
N is the length of the array.
Second line contains the N elements of the array.

Output:
Single number denoting the Count of Zero Xor Subsets of the given array.

Input Constraints:
1<=N<=40
1<=a[i]<=1018

Hint:

Meet in the middle

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

For [1, 2, 3] ,there is only 1 subset (1, 2, 3) having Xor (1 ^ 2 ^3) = 0.
So, the answer is 1.

Editor Image

?