Company: Rakuten
Difficulty: medium
Alice and XOR queries Problem Description Recently, Bob read an article about bitwise operations. He came up with a problem and gave it to Alice to solve. However, Alice is busy doing some work, hence solve the following problem for her. You have an array of integers (initially empty). You are also given an array type where type i denotes the type of the i th query and array X where X i denotes the parameter of the i th query. You have to perform Q queries on this array. Each query belongs to one of three types: type 1: "1 X" – Add the element X to the array type 2: "2 X" – Delete all the occurrences of X in the array type 3: "3 X" – Print the sum of all the elements currently present in the array by taking bitwise XOR with X , i.e. (a 1 ⊕ X) + (a 2 ⊕ X) + (a 3 ⊕ X) + ... + (a N ⊕ X) , where N is the length of the current array. Task: Determine the required sum for each query of type 3.