AMD Interview Question

Can you implement a function to count the number of bits in an integer.

Interview Answer

Anonymous

Mar 13, 2025

int CountBits(int n) { int res = 0 ; while(n > 0) { n = n>>1; res++; } return res; }