博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Leetcode 746. 使用最小花费爬楼梯(DAY 26) ---- 动态规划学习期
阅读量:1993 次
发布时间:2019-04-27

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

原题题目

在这里插入图片描述



代码实现(首刷自解) 一遍遍历 空间(n) 自底向上

int minCostClimbingStairs(int* cost, int costSize){
int dp1,dp2,i,cost1,cost2,tempdp; for(i=0;i
= 2) {
cost1 = cost[i] + dp1; cost2 = cost[i] + dp2; tempdp = ((cost1 < cost2) ? cost1 : cost2); dp1 = dp2; dp2 = tempdp; } else if(!i) dp1 = cost[0]; else dp2 = cost[1]; } return fmin(dp1,dp2);}

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

你可能感兴趣的文章
Android使用Retrofit_00_Getting Started
查看>>
Android使用Retrofit_01_OAuth2 + GitHub
查看>>
Android + Django + OAuth2 + Stub Authenticator
查看>>
诡异的 Scroll view may have only one direct child placed within it 错误
查看>>
【转载】将Ubuntu16.04 中gedit在仅显示一个文件时显示文件名tab
查看>>
调试 LenaCV 3D Camera (Linux)
查看>>
OpenCV杂记 - Mat in C++
查看>>
location区段
查看>>
nginx访问控制、基于用户认证、https配置
查看>>
SaltStack
查看>>
linux内存的寻址方式
查看>>
how2heap-double free
查看>>
how2heap-fastbin_dup_consolidate
查看>>
orw_shellcode_模板
查看>>
fmt在bss段(neepusec_easy_format)
查看>>
python 函数式编程
查看>>
redis cli
查看>>
tensorflow 数据格式
查看>>
tf keras SimpleRNN源码解析
查看>>
tf keras Dense源码解析
查看>>