给出一列数pref,其中pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i],求原数组arr,不断求pref相邻值的异或即可
1 #2433
2 #Runtime: 621 ms (Beats 43.23%)
3 #Memory: 33.2 MB (Beats 7.74%)
4
5 class Solution(object):
6 def findArray(self, pref):
7 """
8 :type pref: List[int]
9 :rtype: List[int]
10 """
11 ans = [pref[0]]
12 for i in xrange(1, len(pref)):
13 ans.append(pref[i] ^ pref[i - 1])
14 return ans