1829. Maximum XOR for Each Query
On This Page
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