Leetcode Note: Go - Decode Xored Array

Decode XORed Array - LeetCode
https://leetcode.com/problems/decode-xored-array/

  • Go 言語で取り組んだメモ

回答

[GO] ~28ms | 98% faster - Decode XORed Array - LeetCode
https://leetcode.com/problems/decode-xored-array/solutions/1059964/go-28ms-98-faster/

func decode(encoded []int, first int) []int {
    da := make([]int, len(encoded)+1)
    da[0]=first
    
    for i, v := range encoded {
        da[i+1] = da[i] ^ v
    }
    
    return da
}