首页 > 其他 > 详细

leetcode746

时间:2018-10-01 18:45:23      阅读:169      评论:0      收藏:0      [点我收藏+]
class Solution {
public:
    int minCostClimbingStairs(vector<int>& cost) {
        vector<int> totol(cost.size(), 0);
        totol[0] = cost[0], totol[1] = cost[1];
        for (int i = 2; i < cost.size(); i++) {
            totol[i] = min(totol[i - 2] + cost[i], totol[i - 1] +cost[i]);
        }
        return min(totol[cost.size() - 1], totol[cost.size() - 2]);
    }
};

 

leetcode746

原文:https://www.cnblogs.com/asenyang/p/9735265.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!