Given an integer array pref of size n, find and return the array arr of size n such that pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i], where ^ is bitwise XOR. The answer is unique.
Given an integer array pref of size n, find and return the array arr of size n such that pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i], where ^ is bitwise XOR. The answer is unique.
Example 1:
Input: {"pref":[5,2,0,3,1]}
Output: [5,7,2,3,2]
Constraints:
1≤pref.length≤105
0≤pref[i]≤106
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"pref":[5,2,0,3,1]}
pref[i] is the XOR of arr[0..i]. Two neighbouring prefixes share everything except arr[i], so XORing them cancels the shared part.