Код: Выделить всё
lets say arr = {1,2,2,1,3,2,1}
1 -> 0001
2 -> 0010
2 -> 0010
1 -> 0001
3 -> 0011
2 -> 0010
1 -> 0001
summing bits -> 0044
n -> no. of repetion, which in this case is 3
modulo of the elements of sum by n -> 0044 % 3 = 0011 = 3
Hence 3 is the answer.
Подробнее здесь: https://stackoverflow.com/questions/783 ... s-except-o