Day i do not know
This commit is contained in:
11
191. Number of 1 Bits/191. Number of 1 Bits.csproj
Normal file
11
191. Number of 1 Bits/191. Number of 1 Bits.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>_191._Number_of_1_Bits</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
9
191. Number of 1 Bits/Program.cs
Normal file
9
191. Number of 1 Bits/Program.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace _191._Number_of_1_Bits;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, World!");
|
||||
}
|
||||
}
|
||||
15
191. Number of 1 Bits/Solution.cs
Normal file
15
191. Number of 1 Bits/Solution.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user