Find XOR sum of Bitwise AND of all pairs from given two Arrays | Function to calculate the XOR sum of all ANDS of all pairs on A [ ] and B [ ] ; variable to store anshu ; when there has been no AND of pairs before this ; Input ; Function call
function XorSum ( A , B , N , M ) { let ans = - 1 ; for ( let i = 0 ; i < N ; i ++ ) { for ( let j = 0 ; j < M ; j ++ ) { if ( ans == - 1 ) ans = ( A [ i ] & B [ j ] ) ; else ans ^= ( A [ i ] & B [ j ] ) ; } } return ans ; } let A = [ 3 , 5 ] ; let B = [ 2 , 3 ] ; let N = A . length ; let M = B . length ; document . write ( XorSum ( A , B , N , M ) ) ;