C++ easy 2 line solution:


#1
unsigned int ans=0;
for(int i=0;i<32;i++){
    ans+=(A&1)<<(31-i);
    A>>=1;
}
return ans;