From 5ac7f6438110a91529b22fc45fb2a52d732cd076 Mon Sep 17 00:00:00 2001 From: xiaoyu2018 <861900161@qq.com> Date: Sun, 25 Sep 2022 16:02:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A00509=E6=96=90=E6=B3=A2?= =?UTF-8?q?=E9=82=A3=E5=A5=91=E6=95=B0C#=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0070.爬楼梯.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/problems/0070.爬楼梯.md b/problems/0070.爬楼梯.md index 0a6acf7f..903e8d58 100644 --- a/problems/0070.爬楼梯.md +++ b/problems/0070.爬楼梯.md @@ -425,5 +425,25 @@ object Solution { } ``` +### C# + +```c# +public class Solution { + public int ClimbStairs(int n) { + if(n<=2) return n; + int[] dp = new int[2] { 1, 2 }; + for (int i = 3; i <= n; i++) + { + int temp = dp[0] + dp[1]; + dp[0] = dp[1]; + dp[1] = temp; + } + return dp[1]; + } +} +``` + + + -----------------------