Count subsequences having odd Bitwise XOR values from an array | C ++ program for the above approach ; Function to count the subsequences having odd bitwise XOR value ; Stores count of odd elements ; Stores count of even elements ; Traverse the array A [ ] ; If el is odd ; If count of odd elements is 0 ; Driver Code ; Given array A [ ] ; Function call to count subsequences having odd bitwise XOR value
#include <bits/stdc++.h> NEW_LINE using namespace std ; void countSubsequences ( vector < int > A ) { int odd = 0 ; int even = 0 ; for ( int el : A ) { if ( el % 2 == 1 ) odd ++ ; else even ++ ; } if ( odd == 0 ) cout << ( 0 ) ; else cout << ( 1 << ( A . size ( ) - 1 ) ) ; } int main ( ) { vector < int > A = { 1 , 3 , 4 } ; countSubsequences ( A ) ; }