Leetcode Note: Go Xor Operation in an Array
XOR Operation in an Array - LeetCode
https://leetcode.com/problems/xor-operation-in-an-array/
- Go 言語で取り組んだメモ
回答
Go - 0 ms, faster than 100.00% of Go - simple solution - XOR Operation in an Array - LeetCode
https://leetcode.com/problems/xor-operation-in-an-array/solutions/1003734/go-0-ms-faster-than-100-00-of-go-simple-solution/
func xorOperation(n int, start int) int {
var output int
for i := 0; i < n; i++ {
output ^= start + 2*i
}
return output
}