C++ Easy Solution Using Shift Operators


#1

unsigned int Solution::reverse(unsigned int A) {
unsigned int ans = 0;
for(int i=0;i<32;i++){
bool x = A&(1<<i);
if(x){
ans+=(1<<(31-i));
}
}
return ans;
}