Interview question is fair? Fastest way to count number of bits in a 32-bit or

Kannan J

New member
64-bit integer.? the answer is that many times you are able to subtract 1 and keep BIT-ANDing till you reach 0.
Now I want to know why they ask this question in software job interviews ? Is there anything intuitive about the solution? What neurons of the brain have to be triggered and how, to arrive at this solution? Doesn't asking this question shows Interviewer's arrogance and incompetence to know what is needed for the job?
 
Back
Top