mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 08:50:15 +08:00
添加0746使用最小花费爬楼梯C#版本
This commit is contained in:
@ -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]);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
-----------------------
|
||||
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>
|
||||
|
Reference in New Issue
Block a user