Decode XORed Array

PHOTO EMBED

Tue Oct 04 2022 18:55:33 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

class Solution {
public:
    vector<int> decode(vector<int>& encoded, int first) {
        vector<int>v;
        int n=encoded.size();
        v.push_back(first);
        for(int i=0;i<n;i++)
        {
            int x=encoded[i]^v[i];
            v.push_back(x);
        }
        return v;
    }
};
content_copyCOPY

Inverse of XOR is XOR itself.

https://leetcode.com/problems/decode-xored-array/