diff --git a/problems/0746.使用最小花费爬楼梯.md b/problems/0746.使用最小花费爬楼梯.md index 9d3bd7fa..4a4c0b65 100644 --- a/problems/0746.使用最小花费爬楼梯.md +++ b/problems/0746.使用最小花费爬楼梯.md @@ -370,5 +370,26 @@ object Solution { } ``` +### C# + +```c# +public class Solution +{ + public int MinCostClimbingStairs(int[] cost) + { + int[] dp=new int[2] { cost[0], cost[1] }; + for (int i = 2; i < cost.Length; i++) + { + int temp = Math.Min(dp[0], dp[1])+cost[i]; + dp[0]=dp[1]; + dp[1]=temp; + } + return Math.Min(dp[0],dp[1]); + } +} +``` + + + -----------------------