题解 | #最小花费爬楼梯#

最小花费爬楼梯

https://www.nowcoder.com/practice/6fe0302a058a4e4a834ee44af88435c7

go
func minCostClimbingStairs( cost []int ) int {
    // write code here
    length := len(cost)
//     fmt.Println(length)
    var dp [1000000]int
    for i:=2;i<=length;i++{
           dp[i] = int(math.Min(float64(dp[i-1]+cost[i-1]),float64(dp[i-2]+cost[i-2])))
    }
    return dp[length]
}
#go语言#
全部评论

相关推荐

皮格吉:不,有的厂子面试无手撕,可以试试。都是一边学一边面。哪有真正准备好的时候,别放弃
无实习如何秋招上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务