@@ -0,0 +1,1615 @@
+/*%0A190. Reverse Bits%0AEasy%0A%0AReverse bits of a given 32 bits unsigned integer.%0A%0AExample 1:%0A%0AInput: 00000010100101000001111010011100%0AOutput: 00111001011110000010100101000000%0AExplanation: The input binary string 00000010100101000001111010011100 represents the unsigned integer 43261596, so return 964176192 which its binary representation is 00111001011110000010100101000000.%0AExample 2:%0A%0AInput: 11111111111111111111111111111101%0AOutput: 10111111111111111111111111111111%0AExplanation: The input binary string 11111111111111111111111111111101 represents the unsigned integer 4294967293, so return 3221225471 which its binary representation is 10111111111111111111111111111111.%0A %0A%0ANote:%0A%0ANote that in some languages such as Java, there is no unsigned integer type. In this case, both input and output will be given as signed integer type and should not affect your implementation, as the internal binary representation of the integer is the same whether it is signed or unsigned.%0AIn Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 2 above the input represents the signed integer -3 and the output represents the signed integer -1073741825.%0A %0A%0AFollow up:%0A%0AIf this function is called many times, how would you optimize it?%0A%0A%0AConstraints:%0A%0AThe input must be a binary string of length = 32%0A*/%0A%0Apublic class Solution %7B%0A    // you need treat n as an unsigned value%0A    public int reverseBits(int n) %7B%0A        int ans = 0;%0A        for (int i = 0; i %3C 32; i++) %7B%0A            ans %3C%3C= 1;%0A            ans = ans %7C (n & 1);%0A            n %3E%3E= 1;%0A        %7D%0A        return ans;%0A    %7D%0A%7D

add p190