4 Line Code ✅| Beats 100%🔥| Easiest Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nUpon reading the problem, the first thing that comes to our mind is how the XOR operati
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUpon reading the problem, the first thing that comes to our mind is how the XOR operation behaves. Since the prefix XOR array is essentially an accumulation of XOR operations, we think the inverse process would involve \'undoing\' the XOR operation. We remember that XOR has the following properties:\n\na \u2295 a = 0\na \u2295 0 = a\n\nXOR operation is both associative and commutative.\nThese properties hint towards the approach of using previous prefix values to deduce the current value.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe first key observation is that the first element of the original array is identical to the first element of the prefix array. This is because there\'s no preceding value to XOR with.\n\nFor each subsequent element in the prefix array, we can determine the corresponding element in the original array by performing an XOR operation between the current prefix value and the previous prefix value. This is derived from the properties of XOR, which allow us to effectively \'cancel out\' or \'undo\' previous accumulations.\n\nUtilizing this approach, we can iterate through the prefix array and populate our original array.\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\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        int n = pref.size();\n        vector<int> ans(n);\n        ans[0] = pref[0];\n\n        for(int i = 1; i < n; i++){\n            ans[i] = pref[i]^pref[i-1];\n        }\n        return ans;\n    }\n};\n```
['Array', 'Bit Manipulation', 'C++']