package leetcode;

/**
 * https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/
 */
public class Problem762 {
    public int countPrimeSetBits(int L, int R) {
        // TODO

        return 0;
    }

    private static boolean isPrime(int n) {
        return n == 2 || n == 3 || n == 5 || n == 7 || n == 11 ||
            n == 13 || n == 17 || n == 19;
    }

    public static void main(String[] args) {
        Problem762 prob = new Problem762();
        System.out.println(prob.countPrimeSetBits(6, 10)); // 4
        System.out.println(prob.countPrimeSetBits(10, 15)); // 5
    }
}

@@ -191,16 +191,180 @@
     
-// TODO%0A
+int result = 0;%0A        for (int i = L; i %3C= R; i++) %7B%0A            int count = count(i);%0A            if (isPrime(count)) %7B%0A                result++;%0A            %7D%0A        %7D
 %0A   
@@ -375,17 +375,22 @@
  return 
-0
+result
 ;%0A    %7D%0A
@@ -413,23 +413,17 @@
 tic 
-boolean isPrime
+int count
 (int
@@ -440,107 +440,169 @@
     
-return n == 2 %7C%7C n == 3 %7C%7C n == 5 %7C%7C n == 7 %7C%7C n == 11 %7C%7C%0A            n == 13 %7C%7C n == 17 %7C%7C n == 19
+int count = 0;%0A        while (n %3E 0) %7B%0A            if ((n & 1) == 1) %7B%0A                count++;%0A            %7D%0A            n %3E%3E= 1;%0A        %7D%0A        return count
 ;%0A  
@@ -615,21 +615,22 @@
    p
-ublic
+rivate
  static 
 void
@@ -629,207 +629,141 @@
 tic 
-void main(String%5B%5D args) %7B%0A        Problem762 prob = new Problem762();%0A        System.out.println(prob.countPrimeSetBits(6, 10)); // 4%0A        System.out.println(prob.countPrimeSetBits(10, 15)); // 5
+boolean isPrime(int n) %7B%0A        return n == 2 %7C%7C n == 3 %7C%7C n == 5 %7C%7C n == 7 %7C%7C n == 11 %7C%7C%0A            n == 13 %7C%7C n == 17 %7C%7C n == 19;
 %0A   

Solve problem 762