2433. Find The Original Array of Prefix Xor ¶ Time: $O(n)$ Space: $O(n)$ C++JavaPython 1 2 3 4 5 6 7 8 9 10 11 12class Solution { public: vector<int> findArray(vector<int>& pref) { vector<int> ans(pref.size()); ans[0] = pref[0]; for (int i = 1; i < ans.size(); ++i) ans[i] = pref[i] ^ pref[i - 1]; return ans; } }; 1 2 3 4 5 6 7 8 9 10 11class Solution { public int[] findArray(int[] pref) { int[] ans = new int[pref.length]; ans[0] = pref[0]; for (int i = 1; i < ans.length; ++i) ans[i] = pref[i] ^ pref[i - 1]; return ans; } } 1 2 3 4 5 6 7 8 9class Solution: def findArray(self, pref: list[int]) -> list[int]: ans = [0] * len(pref) ans[0] = pref[0] for i in range(1, len(ans)): ans[i] = pref[i] ^ pref[i - 1] return ans