@@ -0,0 +1,918 @@
+/**%0A *%09Write a function that takes an unsigned integer and returns the number of %E2%80%991' bits %0A *%09it has (also known as the Hamming weight).%0A *%0A *%09For example, the 32-bit integer %E2%80%9911' has binary representation 00000000000000000000000000001011, %0A *%09so the function should return 3.%0A *%0A *%09Author: matao%0A *%0A */%0Apublic class NumberOf1Bits %7B%0A%09public static int hammingWeight(int n) %7B%0A  // %09int count = 0;%0A  //       while(n %3E 0) %7B%0A  //           if((n & 1) %3E 0) %7B%0A  //               ++count;%0A  //           %7D%0A  //           n %3E%3E= 1;%0A  //       %7D%0A  //       return count;%0A%0A%09%09if(n == 0) %7B%0A%09%09%09return 0;%0A%09%09%7D%0A%09%09int count = 1;%0A%09%09while((n & (n-1)) %3E 0) %7B%0A%09%09%09++count;%0A%09%09%09n &= (n-1);%0A%09%09%7D%0A%09%09return count;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A    %09System.out.println(hammingWeight(0));%0A    %09System.out.println(hammingWeight(1));%0A    %09System.out.println(hammingWeight(3));%0A    %09System.out.println(hammingWeight(10));%0A    %7D%0A%7D

add Number Of 1 Bits solution