URL: https://leetcode.com/problems/sum-of-all-subset-xor-totals/ Signed-off-by: Matej Focko <me@mfocko.xyz>
9 lines
142 B
Go
9 lines
142 B
Go
package main
|
|
|
|
func subsetXORSum(nums []int) int {
|
|
result := 0
|
|
for _, x := range nums {
|
|
result |= x
|
|
}
|
|
return result << (len(nums) - 1)
|
|
}
|