[Python3] if c=a^b then b=c^a beginner friendly!
The key to this problem is to know the reverse XOR!\nif c = a^b then a = c^b and b = c^a\nThen we can go through the pref, keep the XOR of all elements in res s
The key to this problem is to know the reverse XOR!\nif `c = a^b` then `a = c^b` and `b = c^a`\nThen we can go through the `pref`, keep the XOR of all elements in `res` so far, and compute the next element in `res`, append it to `res`.\n```\nclass Solution:\n    def findArray(self, pref: List[int]) -> List[int]:\n        last = pref[0]\n        res = [last] ### the first element in the result is the same as pref\n        for n in pref[1:]:\n            cur = n^last ### compute the current element in result\n            res.append(cur) \n            last ^= cur ### update the XOR of all elements in result so far\n        return res\n```\n\n**Upvote** if you like this post.\n\n**Connect with me on [LinkedIn](https://www.linkedin.com/in/meida-chen-938a265b/)** if you\'d like to discuss other related topics\n\n\uD83C\uDF1F If you are interested in **Machine Learning** || **Deep Learning** || **Computer Vision** || **Computer Graphics** related projects and topics, check out my **[YouTube Channel](https://www.youtube.com/@meidachen8489)**! Subscribe for regular updates and be part of our growing community.
[]