Javascript solution (7 lines)


  • 0
    E
    var reverseBits = function(n) {
        var lst=n.toString(2).split("")
            ,l=lst.length;
        lst.reverse();
        for (var i=0;i<32-l;++i) { lst.push("0"); }
        return parseInt(lst.join(""),2);
    };

Log in to reply
 

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