1. 1 ‘VAL’, for this type of query, you need to insert the integer 'VAL' to the end of the array.
2. 2 ‘VAL’, for this type of query, you need to take the bitwise XOR of all the elements of the array with 'VAL' i.e each element of the array ‘ARR’ will be updated as ‘ARR[i]’ = ‘ARR[i]’ ^ ‘VAL’ ( ^ denotes the bitwise XOR operation).
1) Bitwise XOR operation takes two numbers and performs XOR operation on every bit of those two numbers. For example, consider two numbers 2 and 3 their bitwise XOR will be 1. Because the binary representation of 2 is '10' and the binary representation of 3 is '11'. And XOR of '10' and '11' will be '01'(because XOR evaluates to 0 if the corresponding bits are the same in both the operands, otherwise it evaluates to 1), which is equal to 1.
2) The first query will always be a type 1 query.
3) Note that the ith query should be performed on the array obtained after performing (i-1)th query on the array and so on i.e the changes of each query are updated on the original array itself.
The first line contains an integer ‘T’ which represents the number of test cases.
The first line of each test case contains an integer ‘Q’ denoting the number of queries.
Then each of the ‘Q’ lines contains two space-separated integers denoting the query to be performed.
For each test case, return the updated array after processing all the queries.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= Q <= 10^5
1 <= Val <= 10^9
Time Limit: 1sec
Can you solve this in constant i.e O(1) space complexity? Space used to return the list will not be counted as an extra space.
Longest Subarray With Zero Sum
Merge Two Sorted Arrays Without Extra Space
Ninja And The Strictly Increasing Array
Maximum GCD
Negative To The End