text: Construct original array starting with K from an array of XOR of all elements except elements at same index | C # program for the above approach ; Function to construct an array with each element equal to XOR of all array elements except the element at the same index ; Original array ; Stores Bitwise XOR of array ; Calculate XOR of all array elements ; Print the original array B [ ] ; Driver Code ; Function Call
code: using System ; using System . Collections ; class GFG { static void constructArray ( int [ ] A , int N , int K ) { int [ ] B = new int [ N ] ; int totalXOR = A [ 0 ] ^ K ; for ( int i = 0 ; i < N ; i ++ ) B [ i ] = totalXOR ^ A [ i ] ; for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( B [ i ] + " ▁ " ) ; } } static void Main ( ) { int [ ] A = { 13 , 14 , 10 , 6 } ; int K = 2 ; int N = A . Length ; constructArray ( A , N , K ) ; } }