15 lines
253 B
C#
15 lines
253 B
C#
namespace _191._Number_of_1_Bits;
|
|
|
|
public class Solution
|
|
{
|
|
public int HammingWeight(uint n)
|
|
{
|
|
int count = 0;
|
|
while (n > 0)
|
|
{
|
|
count+=(int)(n & 1);
|
|
n >>= 1;
|
|
}
|
|
return count;
|
|
}
|
|
} |