Skip to content

Commit 1f4ebff

Browse files
authored
Create maximum-xor-for-each-query.py
1 parent bf9ae21 commit 1f4ebff

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Python/maximum-xor-for-each-query.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def getMaximumXor(self, nums, maximumBit):
6+
"""
7+
:type nums: List[int]
8+
:type maximumBit: int
9+
:rtype: List[int]
10+
"""
11+
result = [0]*len(nums)
12+
mask = 2**maximumBit-1
13+
for i in xrange(len(nums)):
14+
mask ^= nums[i]
15+
result[-1-i] = mask
16+
return result

0 commit comments

Comments
 (0)