Queries to replace every array element by its XOR with a given value with updates | C # program of the above approach ; 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
using System ; using System . Collections . Generic ; class GFG { static List < int > arr = new List < int > ( ) ; static int effect ; static void add ( int x ) { arr . Add ( x ) ; } static void update ( int x ) { effect = effect ^ x ; } static void computeResults ( ) { for ( int i = 0 ; i < arr . Count ; i ++ ) { arr [ i ] = arr [ i ] ^ effect ; Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { arr = new List < int > ( ) ; arr . Add ( 0 ) ; effect = 0 ; add ( 5 ) ; update ( 2 ) ; computeResults ( ) ; } }