Share my 1 line JavaScript solution..


  • 0
    var countBits = function(num) {
        return Array(num + 1).fill(0).map((item, index) => index.toString(2).replace(/0/g, '').length);
    };
    

    Only beats 14.6%... ┐(´д`)┌


Log in to reply
 

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