Day i do not know

This commit is contained in:
Electrominch
2022-10-18 00:45:31 +03:00
parent 01c5720116
commit 284b6ff10c
72 changed files with 1256 additions and 12 deletions

View File

@@ -0,0 +1,17 @@
namespace _746._Min_Cost_Climbing_Stairs;
public class Solution
{
public int MinCostClimbingStairs(int[] cost)
{
int prev = cost[0];
int cur = cost[1];
for(int i = 2; i < cost.Length; i++)
{
int next = cost[i] + Math.Min(prev, cur);
prev = cur;
cur = next;
}
return Math.Min(prev, cur);
}
}