There are many numbers in an array and each number appears three times excepting for one special number appearing once. Here is the question: how can I find the special numb
I didnt find the implementation of bitwise mod 3 very intuitive so I wrote a more intiuitive version of the code and tested it with various examples and it worked. Here is the code inside the loop
threes=twos&x //=find all bits counting exactly thrice
x&=~threes //remove the bits countring thrice from x as well as twos
twos&=~threes
twos|=ones&x //find all bits counting exactly twice
x&=~twos //remove all bits counting twice from modified x as well as ones
ones&=~twos
ones|=x //find all the bits from previous ones and modified x
Hope you guys find it easy to understand this version of code.