【每日一题】1720. 解码异或后的数组

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

/*
异或的逆运算还是异或
*/
class Solution {
    public int[] decode(int[] encoded, int first) {
        int[] res = new int[encoded.length + 1];
        res[0] = first;

        for(int i = 0; i < encoded.length; i++){
            res[i + 1] = res[i] ^ encoded[i];
        }
        
        return res;
    }
}
原文地址:https://www.cnblogs.com/realzhaijiayu/p/14736720.html