Prefix XOR
Intuition\n Describe your first thoughts on how to solve this problem. \nIf a^x=b, then b=b^a.\n\n# Approach\n Describe your approach to solving the problem. \n
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf a^x=b, then b=b^a.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe keep xoring the elements of pref[i] using for loop and calculate ans[i].\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> findArray(vector<int>& pref) {\n        \n        vector<int> ans(pref.size(),0);\n        ans[0]=pref[0];\n        int xr=pref[0];\n        for(int i=1; i<pref.size(); i++){\n            \n            ans[i]=pref[i]^xr;\n            xr=xr^ans[i];\n        }\n        return ans;\n    }\n};\n```
['C++']