mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
Update problems/0746.使用最小花费爬楼梯.md
This commit is contained in:
@ -318,7 +318,7 @@ func min(a, b int) int {
|
|||||||
var minCostClimbingStairs = function(cost) {
|
var minCostClimbingStairs = function(cost) {
|
||||||
const dp = [0, 0]
|
const dp = [0, 0]
|
||||||
for (let i = 2; i <= cost.length; ++i) {
|
for (let i = 2; i <= cost.length; ++i) {
|
||||||
dp[i] = Math.min(dp[i -1] + cost[i - 1], dp[i - 2] + cost[i - 2])
|
dp[i] = Math.min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2])
|
||||||
}
|
}
|
||||||
return dp[cost.length]
|
return dp[cost.length]
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user