Too Long; Didn't Read
We find the number of positions at which the corresponding bits are different for the given input. We use the right shift operation, where each bit would have its turn to be shifted to the rightmost position. We shift the bits to left or right and then check if the bit is one or not. We solve this using shifting operation and then we move to solve it in a more optimal way. The algorithm takes at most 32 iterations rather than all the shifting iterations we did in action. Let’s see the code below.