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
def add ( arr , x ) : NEW_LINE INDENT arr . append ( x ) NEW_LINE DEDENT def update ( effect , x ) : NEW_LINE INDENT effect = effect ^ x NEW_LINE return effect NEW_LINE DEDENT def computeResults ( arr , effect ) : NEW_LINE INDENT for i in range ( len ( arr ) ) : NEW_LINE INDENT arr [ i ] = arr [ i ] ^ effect NEW_LINE print ( arr [ i ] , end = " ▁ " ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 0 ] NEW_LINE effect = 0 NEW_LINE add ( arr , 5 ) NEW_LINE effect = update ( effect , 2 ) NEW_LINE computeResults ( arr , effect ) NEW_LINE DEDENT