add missing number finder and some other changes

This commit is contained in:
2022-09-20 01:56:29 +03:00
parent 376ff4255a
commit 5374dd7375
6 changed files with 43 additions and 2 deletions

View File

@@ -1,10 +1,18 @@
// Чудные вхождения в массив
package unique
import "fmt"
func FindUnique(A []int) int {
var result int
for i := 0; i < len(A); i++ {
result = result ^ A[i]
if len(A)%2 != 0 {
for i := 0; i < len(A); i++ {
//xor use
result = result ^ A[i]
}
} else {
fmt.Println("the number of elements is even")
}
return result