1720. Decode XORed Array
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 87% Topics: Array, Bit Manipulation
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(1)
class Solution(object):
def decode(self, encoded, first):
"""
:type encoded: List[int]
:type first: int
:rtype: List[int]
"""
result = [first]
for x in encoded:
result.append(result[-1]^x)
return result
Solution from kamyu104/LeetCode-Solutions · MIT
Similar questions