C++ use bitset


  • 0
    X
    vector<int> countBits(int num) {
    		vector<int> res;
    		for (int i = 0; i <= num; ++i) {
    			res.push_back(bitset<32>(i).count());
    		}
    		return res;
    	}
    

Log in to reply
 

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