Bitwise XOR of all unordered pairs from a given array | Function to get bitwise XOR of all possible pairs of the given array ; Stores bitwise XOR of all possible pairs ; Generate all possible pairs and calculate bitwise XOR of all possible pairs ; Calculate bitwise XOR of each pair ; Driver Code
function TotalXorPair ( arr , N ) { let totalXOR = 0 ; for ( let i = 0 ; i < N ; i ++ ) { for ( let j = i + 1 ; j < N ; j ++ ) { totalXOR ^= arr [ i ] ^ arr [ j ] ; } } return totalXOR ; } let arr = [ 1 , 2 , 3 , 4 ] ; let N = arr . length ; document . write ( TotalXorPair ( arr , N ) ) ;