其他分享
首页 > 其他分享> > 【每日一题】1720. 解码异或后的数组

【每日一题】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;
    }
}

标签:int,res,解码,length,1720,decode,异或,encoded
来源: https://www.cnblogs.com/realzhaijiayu/p/14736720.html