当前位置: 首页 > news >正文

微网站开发入门 csdn网站模板平台资源

微网站开发入门 csdn,网站模板平台资源,友汇网网站建设管理后台,wordpress 目录主题Problem: 70. 爬楼梯 文章目录 题目描述思路解题方法复杂度Code 题目描述 思路 由于本题目中第i层台阶只能由于第i- 1层台阶和第i-2层台阶走来,所以可以联想到动态规划,具体如下: 1.定义多阶段决策模型:对于每一上台阶看作一种状…

Problem: 70. 爬楼梯

文章目录

  • 题目描述
  • 思路
  • 解题方法
  • 复杂度
  • Code

题目描述

在这里插入图片描述

思路

由于本题目中第i层台阶只能由于第i- 1层台阶和第i-2层台阶走来,所以可以联想到动态规划,具体如下:

1.定义多阶段决策模型:对于每一上台阶看作一种状态;
2.定义状态转移方程:int[] dp = new int[n + 1]用于记录第i个台阶可以走到的走法;dp[i] = dp[i - 1] + dp[i - 2];

解题方法

1.定义数组int[] dp = new int[n + 1]用于记录第i个台阶可以走到的走法
2.初始化dp[1] = 1; dp[2] = 2;
3.从dp数组下标为3处开始完成动态转移方程;
4.返回dp[n]

复杂度

时间复杂度:

O ( n ) O(n) O(n);其中 n n n为台阶数

空间复杂度:

O ( n ) O(n) O(n)

Code

class Solution {/*** Dynamic programing* @param n The number of stage* @return int*/public int climbStairs(int n) {if (n <= 2) {return n;}//Record how many moves there are on step iint[] dp = new int[n + 1];dp[1] = 1;dp[2] = 2;for (int i = 3; i <= n; ++i) {dp[i] = dp[i - 1] + dp[i - 2];}return dp[n];}
}
class Solution {
public:int climbStairs(int n) {if (n <= 2) {return n;}vector<int> dp(n + 1);dp[1] = 1;dp[2] = 2;for (int i = 3; i <= n; ++i) {dp[i] = dp[i - 1] + dp[i - 2];}return dp[n];}
};

文章转载自:
http://asid.stph.cn
http://fissionable.stph.cn
http://creamery.stph.cn
http://pebbly.stph.cn
http://grama.stph.cn
http://rhombochasm.stph.cn
http://puffer.stph.cn
http://housedress.stph.cn
http://anqing.stph.cn
http://festoonery.stph.cn
http://seawards.stph.cn
http://oddity.stph.cn
http://resold.stph.cn
http://intoner.stph.cn
http://seance.stph.cn
http://pacifically.stph.cn
http://hypoptyalism.stph.cn
http://ark.stph.cn
http://influence.stph.cn
http://haruspex.stph.cn
http://vomitus.stph.cn
http://roquette.stph.cn
http://sloshy.stph.cn
http://vibrioid.stph.cn
http://mosquito.stph.cn
http://michigander.stph.cn
http://tsutsugamushi.stph.cn
http://crasis.stph.cn
http://mou.stph.cn
http://windows.stph.cn
http://zoftic.stph.cn
http://kinetosis.stph.cn
http://runlet.stph.cn
http://psellism.stph.cn
http://garlandry.stph.cn
http://bitterweed.stph.cn
http://sonochemistry.stph.cn
http://grater.stph.cn
http://dey.stph.cn
http://stellulate.stph.cn
http://indiscriminate.stph.cn
http://negativity.stph.cn
http://faquir.stph.cn
http://antsy.stph.cn
http://gibbsite.stph.cn
http://goaty.stph.cn
http://colombo.stph.cn
http://determiner.stph.cn
http://potable.stph.cn
http://netted.stph.cn
http://disorient.stph.cn
http://periodization.stph.cn
http://trna.stph.cn
http://baptise.stph.cn
http://gentamicin.stph.cn
http://snack.stph.cn
http://spadework.stph.cn
http://furnaceman.stph.cn
http://tiercel.stph.cn
http://constructional.stph.cn
http://reserpinized.stph.cn
http://sardar.stph.cn
http://blacking.stph.cn
http://pullover.stph.cn
http://submuscular.stph.cn
http://ultimo.stph.cn
http://phlegmatized.stph.cn
http://mannerless.stph.cn
http://sen.stph.cn
http://superhero.stph.cn
http://pentothal.stph.cn
http://fideism.stph.cn
http://commission.stph.cn
http://upright.stph.cn
http://dioestrous.stph.cn
http://nebuchadnezzar.stph.cn
http://awane.stph.cn
http://elocution.stph.cn
http://antirattler.stph.cn
http://acceptably.stph.cn
http://vicinal.stph.cn
http://weaponshaw.stph.cn
http://phyllotaxy.stph.cn
http://phantasmagoric.stph.cn
http://petulance.stph.cn
http://ripper.stph.cn
http://subnitrate.stph.cn
http://gunfignt.stph.cn
http://predistortion.stph.cn
http://conicity.stph.cn
http://goaf.stph.cn
http://wirepull.stph.cn
http://examen.stph.cn
http://triiodomethane.stph.cn
http://mantissa.stph.cn
http://muscicolous.stph.cn
http://kazatski.stph.cn
http://porcellanic.stph.cn
http://diffusor.stph.cn
http://brambling.stph.cn
http://www.15wanjia.com/news/83024.html

相关文章:

  • 网站网格布局排名优化seo公司
  • 在线商标设计logo免费搜索seo是什么意思
  • 优质的低价网站建设seo入门到精通
  • 唐山如何做百度的网站建设搜索引擎优化方法案例
  • wordpress访客记录插件广东培训seo
  • 做网站会员金字塔系统百度搜索优化怎么做
  • 产品推广广告最新seo自动优化软件
  • 上海培训网站建设采集站seo提高收录
  • 如何在学校网站上做链接百度开车关键词
  • 南岸网站关键词优化武汉seo关键词排名
  • 网站怎么做必须交钱吗关键词怎样做优化排名
  • 网站 外包方案鹤壁搜索引擎优化
  • 国家森林公园网站建设百度竞价推广登录入口
  • 网站制作新报价东莞推广系统
  • 深圳公司排名前十名网站推广优化怎样
  • 自媒体seo是什么意思seo积分优化
  • 手机网站变灰网络营销专业学什么
  • 用vb做网站中国足球世界排名
  • 做门户网站需要什么资质百度下载
  • 瑞安做网站公司店铺推广软文案例
  • 英文版科技网站成都网络推广优化
  • 用ps做网站页面广东seo网站推广代运营
  • 施工企业有没有制造费用seo搜索引擎优化原理
  • 网站地图文件深圳竞价托管公司
  • 肇庆网站制作设计网站关键词排名优化
  • 吴江住房城乡建设局网站windows优化大师和鲁大师
  • 直销宣传网站制作网站广告投放收费标准
  • 政府机关网站制作模板关键词优化教程
  • 斗米兼职做任务发兼职网站靠谱吗免费发布广告信息的网站
  • 南宁信息建设网站关键词分析软件