Queries to replace every array element by its XOR with a given value with updates | Function to insert an element into the array ; Function to update every array element a [ i ] by a [ i ] ^ x ; Function to compute the final results after the operations ; Driver Code ; Queries ; Function Call
function add ( arr , x ) { arr . push ( x ) ; } function update ( effect , x ) { effect = effect ^ x ; return effect ; } function computeResults ( arr , effect ) { for ( let i = 0 ; i < arr . length ; i ++ ) { arr [ i ] = arr [ i ] ^ effect ; document . write ( arr [ i ] + " " ) ; } } let arr = [ 0 ] ; let effect = 0 ; add ( arr , 5 ) ; effect = update ( effect , 2 ) computeResults ( arr , effect ) ;