Created
May 21, 2023 23:42
-
-
Save thmain/7a9e7aa34343cfa7bd7d9b0ab16a2e48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func getExtraElement(arrA []int, arrB []int) { | |
extraElement := 0 | |
for _, num := range arrA { | |
extraElement ^= num | |
} | |
for _, num := range arrB { | |
extraElement ^= num | |
} | |
fmt.Println("Array A:", arrA) | |
fmt.Println("Array B:", arrB) | |
fmt.Println("Extra Element:", extraElement) | |
} | |
func main() { | |
arrA := []int{3, 4, 5, 2, 9, 6} | |
arrB := []int{4, 3, 2, 9, 5, 7, 6} | |
getExtraElement(arrA, arrB) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment