Skip to content

Practice Find The Original Array of Prefix Xor

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2433
LeetCode Problem

Find The Original Array of Prefix Xor

Problem Statement

Return the unique array arr of the same length as pref such that pref[i] equals the bitwise XOR of arr[0] through arr[i] inclusive, for every i.

Source: Find The Original Array of Prefix Xor on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
pref = [5,2,0,3,1]
Output
[5,7,2,3,2]

# Example 2

Input
pref = [13]
Output
[13]

Constraints

1 <= pref.length <= 10^5
0 <= pref[i] <= 10^6

Related LeetCode Problems

Practice more problems similar to Find The Original Array of Prefix Xor.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.