Tap here to switch tabs
Problem
Submissions

Problem: Find The Original Array of Prefix Xor

Find The Original Array of Prefix Xor gives an array of running bitwise XOR values and asks you to return the unique original array that produces them in order.

Statement

You are given an integer array pref of length nn.

Find and return the array arr of length nn that satisfies:

pref[ii] = arr[00] ^ arr[11] ^ ... ^ arr[ii]

for all indices ii such that 0≤i<n0 \leq i < n, where ^ denotes the bitwise XOR operation.

Note: It can be proven that the resulting array arr is unique.

Constraints:

  • 1≤1 \leq pref.length ≤105\leq 10^5

  • 0≤0 \leq pref[i] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find The Original Array of Prefix Xor

Find The Original Array of Prefix Xor gives an array of running bitwise XOR values and asks you to return the unique original array that produces them in order.

Statement

You are given an integer array pref of length nn.

Find and return the array arr of length nn that satisfies:

pref[ii] = arr[00] ^ arr[11] ^ ... ^ arr[ii]

for all indices ii such that 0≤i<n0 \leq i < n, where ^ denotes the bitwise XOR operation.

Note: It can be proven that the resulting array arr is unique.

Constraints:

  • 1≤1 \leq pref.length ≤105\leq 10^5

  • 0≤0 \leq pref[i] ≤106\leq 10^6