Count pairs with Odd XOR | A function will return number of pair whose XOR is odd ; To store count of odd and even numbers ; Increase even if number is even otherwise increase odd ; Return number of pairs ; Driver Code
< ? php function countXorPair ( $ arr , $ n ) { $ odd = 0 ; $ even = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { if ( $ arr [ $ i ] % 2 == 0 ) $ even ++ ; else $ odd ++ ; } return $ odd * $ even ; } $ arr = array ( 1 , 2 , 3 ) ; $ n = sizeof ( $ arr ) ; echo countXorPair ( $ arr , $ n ) ; ? >