XOR of all possible pairwise sum from two given Arrays | Function to calculate the sum of XOR of the sum of every pair ; Stores the XOR of sums of every pair ; Iterate to generate all possible pairs ; Update XOR ; Return the answer ; Driver Code
function XorSum ( A , B , N ) { var ans = 0 ; for ( i = 0 ; i < N ; i ++ ) { for ( j = 0 ; j < N ; j ++ ) { ans = ans ^ ( A [ i ] + B [ j ] ) ; } } return ans ; } var A = [ 4 , 6 , 0 , 0 , 3 , 3 ] ; var B = [ 0 , 5 , 6 , 5 , 0 , 3 ] ; var N = A . length ; document . write ( XorSum ( A , B , N ) ) ;