add missing number finder and some other changes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user