Python List Comprehension -- One Line Solution 🔥
Intuition\nThe problem requires us to find an array "arr" such that pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i].\nWe can observe that pref[i] can be calculated as 
# Intuition\nThe problem requires us to find an array "arr" such that pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i].\nWe can observe that pref[i] can be calculated as follows:\npref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i]\npref[i-1] = arr[0] ^ arr[1] ^ ... ^ arr[i-1]\npref[i] ^ pref[i-1] = (arr[0] ^ arr[1] ^ ... ^ arr[i]) ^ (arr[0] ^ arr[1] ^ ... ^ arr[i-1])\nIf we simplify the XOR operation, we get arr[i] = pref[i] ^ pref  [i-1].\n# Approach\nWe can use the above observation to find the elements of the array "arr" by iterating through the "pref" array.\nInitialize an empty list "arr".\nFor the first element of "arr", add pref[0].\nThen, iterate from i = 1 to len(pref) - 1, and for each i, calculate arr[i] as pref[i] ^ pref[i-1] and append it to "arr".\nReturn the "arr" as the result.\n# Complexity\n- Time complexity:\n O(n)\n\n- Space complexity:\n O(n)\n\n# Code\n```\nclass Solution:\n    def findArray(self, pref: List[int]) -> List[int]:\n        return [pref[0]]+[(pref[i-1]^pref[i]) for i in range(1,len(pref))]\n```
['Python3']