MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / countBit_fast

Function countBit_fast

CPP/bitmasking/count_bits.cpp:17–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15 return count;
16}
17int countBit_fast(int n){
18 int ans=0;
19 while(n>0){
20 n=n&(n-1);
21 ans++;
22 }
23 return ans;
24}
25int main(){
26 cin.tie(0)->sync_with_stdio(0);
27 int n;

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected