Decode XORed Permutation LeetCode solution in Python
1# Runtime: 1921 ms (Top 32.18%) | Memory: 33.8 MB (Top 16.09%)23from functools import reduce4from operator import xor567class Solution:89def decode(self, encoded: List[int]) -> List[int]:10n = len(encoded) + 111a = reduce(xor, range(1, n + 1))12b = reduce(xor, encoded[1::2])13result = [a ^ b]14for y in encoded:15result.append(result[-1] ^ y)16return result