C++ solution without using shift operator


#1
unsigned int Solution::reverse(unsigned int A) {
    if(A == 0) return 0;
    unsigned long int sum = 0;
    int rem;
    for(int i=0; i<32; i++){
        rem = A%2;
        A = A/2;
        if(rem == 1){
            sum = sum + pow(2, 31-i);
        }
    }
    return sum;
}

#2

did you know that shifting is same as multiplying by a power of 2?