Why this solution doesn't work?


  • -1
    S
    public int reverseBits(int n) {
            int res=0;
            for(int i=31;i>=0;i--){
                int bit=n&1;
                n=n>>1;
                res=res+bit*(int)Math.pow(2,i);
                
            }
            
            return res;
            
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.