go: add «1863. Sum of All Subset XOR Totals»
URL: https://leetcode.com/problems/sum-of-all-subset-xor-totals/ Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
c6b7b034de
commit
23deeef141
1 changed files with 9 additions and 0 deletions
9
go/sum-of-all-subset-xor-totals.go
Normal file
9
go/sum-of-all-subset-xor-totals.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package main
|
||||
|
||||
func subsetXORSum(nums []int) int {
|
||||
result := 0
|
||||
for _, x := range nums {
|
||||
result |= x
|
||||
}
|
||||
return result << (len(nums) - 1)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue