reverse binary representation of number code example
Example: reverse binary representation of a number
long long reversedBits(long long X) {
long long p = 1;
long long ans = 0;
while(X>0){
int last_bit = (X&1);
ans = ans + p*last_bit;
p = p*10;
X=X>>1;
}
return ans;
}