Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save sreeprasad/9f14790b9f68495af1d46b29c97c0bcd to your computer and use it in GitHub Desktop.

Select an option

Save sreeprasad/9f14790b9f68495af1d46b29c97c0bcd to your computer and use it in GitHub Desktop.
Find the number of bits set in O(K) where K is the number of bits set
int findCount(int N) {
while(N>0){
count++;
N= N&(N-1);
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment