XOR of pairwise sum of every unordered pairs in an array | Java implementation to find XOR of pairwise sum of every unordered pairs in an array ; Function to find XOR of pairwise sum of every unordered pairs ; Loop to choose every possible pairs in the array ; Driver Code
class GFG { static int xorOfSum ( int a [ ] , int n ) { int answer = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) answer ^= ( a [ i ] + a [ j ] ) ; } return answer ; } public static void main ( String [ ] args ) { int n = 3 ; int A [ ] = { 1 , 2 , 3 } ; System . out . print ( xorOfSum ( A , n ) ) ; } }