C++ | Simple Approach | 5 Lines of Code | Explained
Idea : If you see test cases resultant array is just xor of pref[i] and pref[i-1] \nAlso remember XOR operator follows associativity \n\npush_back(pref[0]);\nth
Idea : If you see test cases resultant array is just xor of pref[i] and pref[i-1] \nAlso remember XOR operator follows associativity \n\npush_back(pref[0]);\nthen res[i] is xor of all elements upto ith element\n```\nclass Solution {\npublic:\n    vector<int> findArray(vector<int>& pref) {\n        vector<int> res;  // this will be our result array\n        res.push_back(pref[0]);\n        \n        for(int i=1;i<pref.size();i++){\n            res.push_back(pref[i] xor pref[i-1]);\n        }\n        \n        return res;\n    }\n};\n```
['C', 'C++']