C# solution: loop 32 times


  • 0
    B
    public class Solution 
    {
        public uint reverseBits(uint n) 
        {
            uint result = 0;
            int count = 31;
            while(count >= 0)
            {
                result |= (n & 1) << count;
                n >>= 1;
                count--;
            }
    
            return result;
        }
    }
    

Log in to reply
 

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