Created
June 28, 2018 14:12
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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