Stupid but fast solution for c++

  • 1
    R says my code beats 100% ppl in c++ (for c++ only).
    not the fastest solution among all the languages though.
    just for your reference.

    class Solution {
        vector<int> countBits(int num) {
            vector<int> array(1,0) ;
            int power=-1;
            int temp;
            while (num >= (2^power))
            {   power++;
                int size=array.size();
                for(int i=0;i<size;i++)
                {    if (array.size()>num)
            return array;

Log in to reply

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