Count subsequences having odd Bitwise XOR values from an array | Java 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
import java . io . * ; class GFG { public static void countSubsequences ( int [ ] A ) { int odd = 0 ; int even = 0 ; for ( int el : A ) { if ( el % 2 == 1 ) odd ++ ; else even ++ ; } if ( odd == 0 ) System . out . println ( 0 ) ; else System . out . println ( 1 << ( A . length - 1 ) ) ; } public static void main ( String [ ] args ) { int [ ] A = { 1 , 3 , 4 } ; countSubsequences ( A ) ; } }