3 line code , using bitset


#1

#include<bitset>
unsigned int Solution::reverse(unsigned int A) {

bitset<32> b(A), temp;

for(int i=0;i<32;i++) temp[i]=b[31-i];

return temp.to_ulong();

}