1829. Maximum XOR for Each Query

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1829

class Solution:
    def getMaximumXor(self, nums: List[int], maximumBit: int) -> List[int]:
        res = []
        xs = reduce(xor, nums)
        mask = (1 << maximumBit) - 1
        for x in nums[::-1]:
            k = xs ^ mask
            res.append(k)
            xs ^= x
        return res