URL: https://leetcode.com/problems/bitwise-xor-of-all-pairings/ Signed-off-by: Matej Focko <me@mfocko.xyz>
19 lines
327 B
Go
19 lines
327 B
Go
package main
|
|
|
|
func xorAllNums(nums1 []int, nums2 []int) int {
|
|
xorFold := func(nums []int, otherLength int) int {
|
|
acc := 0
|
|
if otherLength%2 == 0 {
|
|
return acc
|
|
}
|
|
|
|
for _, num := range nums {
|
|
acc ^= num
|
|
}
|
|
|
|
return acc
|
|
}
|
|
|
|
xor1, xor2 := xorFold(nums1, len(nums2)), xorFold(nums2, len(nums1))
|
|
return xor1 ^ xor2
|
|
}
|