Practice Decode XORed Permutation
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
There is an integer array perm that is a permutation of the first n positive integers, where n is always odd. It was encoded into another integer array encoded of length n - 1, such that encoded[i] = perm[i] XOR perm[i + 1]. For example, if perm = [1,3,2], then encoded = [2,1]. Given the encoded array, return the original array perm. It is guaranteed that the answer exists and is unique.
Source: Decode XORed Permutation on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
encoded = [3,1]
[1,2,3]
# Example 2
encoded = [6,5,4,6]
[2,4,1,5,3]
Constraints
Related LeetCode Problems
Practice more problems similar to Decode XORed Permutation.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.