Tap here to switch tabs
Problem
Submissions

Problem: Decode XORed Permutation

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

Statement

There is an integer array perm that represents a permutation of the first nn positive integers from 11 to nn.

This array was transformed into an integer array encoded of length n−1n - 1, where encoded[i] = perm[i] XOR perm[i + 1] for each ii (0≤i<n−10 \leq i < n - 1).

Given the array encoded, reconstruct and return the original array perm. It is guaranteed that the answer exists and is unique.

Constraints:

  • 3≤n<1053 \leq n < 10^5

  • nn is odd.

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Decode XORed Permutation

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

Statement

There is an integer array perm that represents a permutation of the first nn positive integers from 11 to nn.

This array was transformed into an integer array encoded of length n−1n - 1, where encoded[i] = perm[i] XOR perm[i + 1] for each ii (0≤i<n−10 \leq i < n - 1).

Given the array encoded, reconstruct and return the original array perm. It is guaranteed that the answer exists and is unique.

Constraints:

  • 3≤n<1053 \leq n < 10^5

  • nn is odd.

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