Count pairs with odd Bitwise XOR that can be removed and replaced by their Bitwise OR | Function to count the number of pairs required to be removed from the array and replaced by their Bitwise OR values ; Stores the count of even array elements ; Traverse the given array ; Increment the count of even array elements ; If the array contains at least one odd array element ; Otherwise , print 0 ; Driver Code
function countPairs ( arr , N ) { let even = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 0 ) even ++ ; } if ( N - even >= 1 ) { document . write ( even ) ; return ; } document . write ( 0 ) ; } let arr = [ 5 , 4 , 7 , 2 ] ; let N = arr . length ; countPairs ( arr , N ) ;