Reverse XOR
Please upvote if find helpful :)\n\npref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i]\npref[i] is the calculated XOR array of 0 to i elements\n\nNow let\'s analyze the i
**Please upvote if find helpful :)**\n\n```pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i]```\npref[i] is the calculated XOR array of 0 to i elements\n\nNow let\'s analyze the input\n```\nInput: pref = [5,2,0,3,1]\nOutput: [5,7,2,3,2]\nExplanation: From the array [5,7,2,3,2] we have the following:\n- pref[0] = 5.\n- pref[1] = 5 ^ 7 = 2.\n- pref[2] = 5 ^ 7 ^ 2 = 0.\n- pref[3] = 5 ^ 7 ^ 2 ^ 3 = 3.\n- pref[4] = 5 ^ 7 ^ 2 ^ 3 ^ 2 = 1.\n\nfor i=0 , 5 is the answer\nfor i=1 , 5 ^ x = 2 , we need value of x , to get value of x we can do XOR on both sides with 5\n            5 ^ x ^ 5 =2 ^5 , x=2^5 , x=2 ^ prev\nfor i=2 , 5 ^ 7 ^ x = 0 , to get x same XOR on both sides with ( 5 ^ 7 ) but 5 ^ 7 can be represented with 2 which is the last value of pref             \n```\n\n#### CODE\n```\nvector<int> findArray(vector<int>& pref) {\n        vector<int>ans;\n        int prev=0;\n        for(int &p:pref){\n            ans.push_back(p^prev);\n            prev=p;\n        }\n        return ans;\n    }\n```
['C++']