C++ xor||59ms Beats 99.71%
Intuition\n Describe your first thoughts on how to solve this problem. \nBased on the formula:\n\nx ^y= z\n=> (x^y)^y =z^y \n=> x^(y^y)=z^y (associative)\n=> x^
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBased on the formula:\n```\nx ^y= z\n=> (x^y)^y =z^y \n=> x^(y^y)=z^y (associative)\n=> x^0=z^y\n=> x=z^y\n```\nSame as modulo 2 addition!\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThis for-loop implements the XOR computation.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n# Code\n```\n#pragma GCC optimize("O3")\nclass Solution {\npublic:\n    vector<int> findArray(vector<int>& pref) {\n        int n=pref.size();\n        vector<int> ans(n);\n        ans[0]=pref[0];\n        for(int i=1; i<n; i++)\n            ans[i]=pref[i-1]^pref[i];\n        return  ans;\n    }\n};\nauto init = []()\n{ \n    ios::sync_with_stdio(0);\n    cin.tie(0);\n    cout.tie(0);\n    return \'c\';\n}();\n```
['Array', 'Bit Manipulation', 'C++']