Pergunta de entrevista da empresa AppLogic Networks

How would you count the number of set bits in a binary representation of an integer?

Resposta da entrevista

Sigiloso

11 de fev. de 2017

int Set_Bits (int a) { int counter = 0; //a is the int while( a != 0 ) { a&= a -1; counter++; } return counter; }