//sample solution
function onesCount(x)
{
var count=0;
while(x){
count++;
x = x & (x - 1);
}
return count;
}
function rangeBitCount(a, b) {
var sumOfOnesCount = 0;
for(i=a; i<=b; i++){
sumOfOnesCount = sumOfOnesCount + onesCount(i);
}
return sumOfOnesCount;
}
No comments:
Post a Comment