<s>[INST] class Solution {
public:
    int countPrimeSetBits(int L, int R) {
        bool isPrime[33] = {false};
        int count = 0;
        for(int i = 2; i <= 32; i++) {
            isPrime[i] = true;
        }
        for(int i = 2; i <= 32; i++) {
            if(isPrime[i]) {
                for(int j = i * 2; j <= 32; j += i) {
                    isPrime[j] = false;
                }
            }
        }
        for(int i = L; i <= R; i++) {
            int num = i;
            int bitcount = 0;
            while(num) {
                bitcount += num & 1;
                num >>= 1;
            }
            if(isPrime[bitcount])
                count++;
        }
        return count;
    }
};

This is my code for LeetCode's [762. Prime Number of Set Bits in Binary Representation](https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/db-session/16005016953087791024/).
The above code has a time complexity of O(n log n). Is it possible to do it in O(n)?[/INST]