Re: [闲聊] 每日leetcode

楼主: DJYOMIYAHINA (通通打死)   2024-11-08 23:13:45
拐弯抹角的题目
可能也因为这样所以才是medium吧= =
def getMaximumXor(self, nums: List[int], maximumBit: int) -> List[int]:
ans = []
mask = 2**(maximumBit)-1
cur_xor = 0
for num in nums:
cur_xor = cur_xor ^ num
ans.append((~(cur_xor&mask))&mask)
return ans[::-1]
作者: Meaverzt (Meaverzt)   2024-11-08 23:20:00
大师

Links booklink

Contact Us: admin [ a t ] ucptt.com