Tap here to switch tabs
Problem
Submissions

Problem: Decode XORed Array

med
30 min
Try to solve the Decode XORed Array problem.

Statement

There is a hidden integer array arr containing nn elements that was transformed into an array encoded of length n−1n - 1 such that encoded[i] = arr[i] ^ arr[i + 1] for all valid indices ii.

Given the integer array encoded and an integer first representing the initial element arr[0], reconstruct and return the original array arr.

Constraints:

  • 2≤n≤1042 \le n \le 10^4

  • encoded.length ==n−1== n - 1

  • 0≤0 \le encoded[i] ≤105\le 10^5

  • 0≤0 \le first ≤105\le 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Decode XORed Array

med
30 min
Try to solve the Decode XORed Array problem.

Statement

There is a hidden integer array arr containing nn elements that was transformed into an array encoded of length n−1n - 1 such that encoded[i] = arr[i] ^ arr[i + 1] for all valid indices ii.

Given the integer array encoded and an integer first representing the initial element arr[0], reconstruct and return the original array arr.

Constraints:

  • 2≤n≤1042 \le n \le 10^4

  • encoded.length ==n−1== n - 1

  • 0≤0 \le encoded[i] ≤105\le 10^5

  • 0≤0 \le first ≤105\le 10^5