Блог пользователя hexor

Автор hexor, 13 лет назад, По-английски

Can you give me a some trick for xor( exclusive or ) operation?

  • Проголосовать: нравится
  • +17
  • Проголосовать: не нравится

»
13 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +8 Проголосовать: не нравится

Given an array of positive integers. Let's assume that every value except one repeat an even number of times. The question is: find the only value that repeats an odd number of times.

For example, if the array is: 6 8 8 6 3 9 3 9 3 the answer is 3, because it repeats an odd number of times.

For the solution, see "Rev. 1" of this comment :)

»
13 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Here you can find some tricks for bit operations http://graphics.stanford.edu/~seander/bithacks.html