Maximum subset XOR
Submissions: 2173   Accuracy:

23.94%

  Difficulty: Hard   Marks: 8

Given a set of positive integers. The task is to complete the function maxSubarrayXOR which returns an integer denoting the maximum XOR subset value in the given set.

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

Output Format:
For each test case in a new line output will be the maximum XOR subset value in the given set.

Your Task:
You need to complete the function maxSubarrayXOR.

Constraints:
1 <= T <= 100
1 <= N <= 50

Example:
Input:

2
3
2 4 5
3
9 8 5
Output:
7
13

Explanation:
Testcase1:
Input: set[] = {2, 4, 5}
Output: 7
The subset {2, 5} has maximum XOR value
Testcase2:
Input: set[] = {9, 8, 5}
Output: 13
The subset {8, 5} has maximum XOR value

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

Contributor: Harshit Sidhwa
Author: Shubham Joshi 1


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

to report an issue on this page.