Given an array pref where pref[i] is the XOR of the first i + 1 elements of the original array, return the original array. Pattern focus: XOR State Tracking. The current prefix state can be undone by XORing consecutive prefix values.
pref = prefix XOR array
the original array
Example 1:
Input:
pref = [5,2,0,3,1]
Output:
[5,7,2,3,2]
Explanation:
Each original value is pref[i] XOR pref[i-1].
Example 2:
Input:
pref = [13]
Output:
[13]
Explanation:
A single prefix XOR value means the original array has one element.