Easy C++ Solution (Bit manipulation- Easy Method)
Intuition\nInitialize an empty vector v to store the elements of the arr.\n\nInitialize first to 0. This variable represents the cumulative XOR of elements in a
# Intuition\nInitialize an empty vector v to store the elements of the arr.\n\nInitialize first to 0. This variable represents the cumulative XOR of elements in arr from index 0 to the current index, and it starts with 0 since there are no elements in arr initially.\n\nIterate through the elements of pref using a loop. For each element x in pref:\n\nCompute temp as the XOR of x and the current value of first. This represents the value of arr[i] at the current index.\nPush temp onto the v vector.\nUpdate the first value by performing an XOR between the current first and temp. This updates the cumulative XOR value.\nAfter the loop, v will contain the elements of arr, and you can return it as the result.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n\n\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$\n  The code iterates through each element in the pref array exactly once, performing constant-time operations within the loop (XOR and vector operations). Therefore, the time complexity is $$O(n)$$, where n is the size of the pref array.\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: \n  The code uses a vector v to store the elements of arr, which has the same size as the pref array. Therefore, the space complexity is $$O(n)$$, where n is the size of the pref array. The additional space complexity is $$O(1)$$ for other variables used in the solution.\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Please Upvote if you find useful :)\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> findArray(vector<int>& pref) {\n        vector <int> v ;\n        int first = 0;\n        int temp ;\n        for(auto x:pref){\n            temp = x ^ first;\n            v.push_back(temp);\n            first = first^temp ;\n        }\n        return v ;\n    }\n};\n```
['Math', 'Bit Manipulation', 'C', 'C++']