Construct original array starting with K from an array of XOR of all elements except elements at same index | 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
function constructArray ( A , N , K ) { let B = new Array ( N ) ; let totalXOR = A [ 0 ] ^ K ; for ( let i = 0 ; i < N ; i ++ ) B [ i ] = totalXOR ^ A [ i ] ; for ( let i = 0 ; i < N ; i ++ ) { document . write ( B [ i ] + " " ) ; } } let A = [ 13 , 14 , 10 , 6 ] , K = 2 ; let N = A . length ; constructArray ( A , N , K ) ;