Subset XOR


Given a set S. Generate T, a set that contains all subsets of S minus the null set and calculate A, XOR sum of the set T. \n\nS={1,2,3}\nT={{1},{2},{3},{1,2},{1,3},{2,3} ,{1,2,3}}\nA=XORiana of T .\nXORiana of a set is defined as XOR of all the elements it contains.\n\nConstraints:\n1<=T<=100\n1<=N<=100\n0<=Array[i]<=200.


#include <iostream>
using namespace std;
// Returns XOR of all XOR's of given subset
int findXOR(int Set[], int n)
    // XOR is 1 only when n is 1, else 0
    if (n == 1)
       return Set[0];
       return 0;
// Driver program
int main()
  int arr[10],tc,n;
  for(int i=0;i<tc;i++)
    for(int j=0;j<n;j++)
    //int Set[] = {1, 2, 3};
    //int n = sizeof(Set)/sizeof(Set[0]);
    cout<< findXOR(arr, n);
    return 0;
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
CHP Adblock Detector Plugin | Codehelppro