You are viewing a single comment's thread. Return to all comments →
Those who have put the solution using XOR, It does not work for some cases, check below code,
arr := []int{2, 2, 1, 3, 1, 2, 4, 3} count := 0 for _, e := range arr { count ^= e fmt.Println("count", count) } fmt.Println(count)
Output: The output is 6, instead of 4.
Seems like cookies are disabled on this browser, please enable them to open this website
Lonely Integer
You are viewing a single comment's thread. Return to all comments →
Those who have put the solution using XOR, It does not work for some cases, check below code,
Output: The output is 6, instead of 4.