Tap here to switch tabs
Problem
Submissions

Problem: Find The Original Array of Prefix Xor

med
30 min
Try to solve the Find The Original Array of Prefix Xor problem.

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

med
30 min
Try to solve the Find The Original Array of Prefix Xor problem.

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