-
Notifications
You must be signed in to change notification settings - Fork 197
Open
Description
I saw your solution when I was looking for an efficient way to do this operation - but later came up with an alternative approach:
This is much faster.
var countBits = function(n) {
var count = 0;
while (n != 0)
{
n = n & (n-1);
count++;
}
return count;;
}
I thought I would share since it might be useful to you.
Metadata
Metadata
Assignees
Labels
No labels