1720. 解码异或后的数组
为保证权益,题目请参考 1720. 解码异或后的数组(From LeetCode).
解决方案1
Python
python
from typing import List
class Solution:
def decode(self, encoded: List[int], first: int) -> List[int]:
ans = [0 for i in range(len(encoded)+1)]
ans[0] = first
for i in range(1, len(encoded)+1):
ans[i] = encoded[i-1] ^ ans[i-1]
return ans
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10