Posted on

Description

Submission

class Solution {
public:
    vector<int> decode(vector<int>& encoded) {
        int n = encoded.size();
        vector<int> perms(n+1, 0);
        for(int i = 0; i < n+1; ++i) perms[0] ^= (i+1);
        for(int i = 1; i < n; i += 2) perms[0] ^= encoded[i];
        for(int i = 1; i < n + 1; ++i) perms[i] = perms[i-1] ^ encoded[i-1];
        return perms;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *