Day10
This commit is contained in:
11
70. Climbing Stairs/70. Climbing Stairs.csproj
Normal file
11
70. Climbing Stairs/70. Climbing Stairs.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>_70._Climbing_Stairs</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
9
70. Climbing Stairs/Program.cs
Normal file
9
70. Climbing Stairs/Program.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace _70._Climbing_Stairs;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, World!");
|
||||
}
|
||||
}
|
||||
19
70. Climbing Stairs/Solution.cs
Normal file
19
70. Climbing Stairs/Solution.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace _70._Climbing_Stairs;
|
||||
|
||||
public class Solution
|
||||
{
|
||||
public int ClimbStairs(int n)
|
||||
{
|
||||
if (n == 0)
|
||||
return 0;
|
||||
int cur0 = 0;
|
||||
int cur1 = 1;
|
||||
while (--n > 0)
|
||||
{
|
||||
int buf = cur0 + cur1;
|
||||
cur0 = cur1;
|
||||
cur1 = buf;
|
||||
}
|
||||
return cur0 + cur1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user