Single list-comprehension (without concat or ifs) using walrus operator
Additional solution to the list, this time using python\'s walrus operator which allows us to build the array result in a single list comprehension expression.\
Additional solution to the list, this time using python\'s `walrus operator` which allows us to build the array result in a single list comprehension expression.\nWith the idea of `i++` in other languages, we use the value of `x` and assign it to `last` for the next iteration.\n\nExample:\n```\nlast = 3\nx = 7\nresult = last^(last:=x)\n\n# After evaluating `result`, each variable equals to:\n# result = 3^7 = 4\n# last = 7\n# x = 7\n```\n\nAdd this to a list comprehension and you get a less-readable but faster array construction. It turns out to also be shorter than other one-liner solutions.\n\n\n# Code\n```\nclass Solution:\n    def findArray(self, pref: List[int]) -> List[int]:\n        last = 0\n        return [last^(last:=x) for x in pref]\n```
['Python3']