Count pairs with Bitwise AND as ODD number | Java program to count pairs with AND giving a odd number ; Function to count number of odd pairs ; variable for counting odd pairs ; find all pairs ; find AND operation check odd or even ; return number of odd pair ; Driver Code ; calling function findOddPair and print number of odd pair
class solution_1 { static int findOddPair ( int A [ ] , int N ) { int i , j ; int oddPair = 0 ; for ( i = 0 ; i < N ; i ++ ) { for ( j = i + 1 ; j < N ; j ++ ) { if ( ( A [ i ] & A [ j ] ) % 2 != 0 ) oddPair ++ ; } } return oddPair ; } public static void main ( String args [ ] ) { int a [ ] = { 5 , 1 , 3 , 2 } ; int n = a . length ; System . out . println ( findOddPair ( a , n ) ) ; } }