add: 220215 [golang]

This commit is contained in:
Lam Haoyin 2022-02-15 12:18:27 +08:00
parent 61f66c394f
commit d042dba79e
No known key found for this signature in database
GPG Key ID: 8C089CB1A2B7544F
1 changed files with 16 additions and 0 deletions

16
2202/220215.go Normal file
View File

@ -0,0 +1,16 @@
package main
import "fmt"
func singleNumber(nums []int) int {
var x = 0
for _, v := range nums {
x ^= v
}
return x
}
func main() {
var args = []int{4, 1, 2, 1, 2}
fmt.Println(singleNumber(args))
}