博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
力扣网 | 每日打卡题 | 746. 使用最小花费爬楼梯
阅读量:4140 次
发布时间:2019-05-25

本文共 297 字,大约阅读时间需要 1 分钟。

文章目录

题目

解析

动态规划

爬楼梯!

class Solution {
public: int minCostClimbingStairs(vector
& cost) {
int a=0,b=0,sum=0,len=cost.size(); for(int i=2;i<=len;i++){
sum=min(a+cost[i-2],b+cost[i-1]); a=b; b=sum; } return sum; }};

转载地址:http://gzevi.baihongyu.com/

你可能感兴趣的文章
第七章 背包问题——完全背包
查看>>
51nod 分类
查看>>
1136 . 欧拉函数
查看>>
面试题:强制类型转换
查看>>
Decorator模式
查看>>
Template模式
查看>>
Observer模式
查看>>
高性能服务器设计
查看>>
性能扩展问题要趁早
查看>>
MySQL-数据库、数据表结构操作(SQL)
查看>>
OpenLDAP for Windows 安装手册(2.4.26版)
查看>>
图文介绍openLDAP在windows上的安装配置
查看>>
Pentaho BI开源报表系统
查看>>
Pentaho 开发: 在eclipse中构建Pentaho BI Server工程
查看>>
JSP的内置对象及方法
查看>>
android中SharedPreferences的简单例子
查看>>
android中使用TextView来显示某个网址的内容,使用<ScrollView>来生成下拉列表框
查看>>
andorid里关于wifi的分析
查看>>
Spring MVC和Struts2的比较
查看>>
Hibernate和IBatis对比
查看>>