当前位置:网站首页>JZ69 跳台阶
JZ69 跳台阶
2022-08-02 15:35:00 【syc596】
JZ69 跳台阶
NC68 跳台阶
// //递归
// public class Solution {
// public int jumpFloor(int target) {
// if(target==0) return 0;
// if(target==1) return 1;
// if(target==2) return 2;
// return jumpFloor(target-1)+jumpFloor(target-2);
// }
// }
//动规
public class Solution {
public int jumpFloor(int target) {
if(target==0) return 0;
if(target==1) return 1;
if(target==2) return 2;
int[] dp=new int[target+1];
dp[0]=1;
dp[1]=1;
dp[2]=2;
for(int i=3;i<=target;i++){
dp[i]=dp[i-1]+dp[i-2];
}
return dp[target];
}
}
边栏推荐
猜你喜欢
随机推荐
2.6 - 进程资源
软件成分分析:华为云重磅发布开源软件治理服务
不平衡之钥: 重采样法何其多
节省50%成本!京东云重磅发布新一代混合CDN产品
【暑期集训第一周:搜索】【DFS&&BFS】
CS5210的参数详情资料分享
Go-4-在vim中无法跳转到源代码
亏损扩大/毛利偏低,北斗智联与「智能座舱第一阵营」的不等号
NC52 有效括号序列
JZ27 二叉树的镜像
第十五天笔记
24、wpf之布局(二)
数仓:金融级数仓架构转型的最佳实践(下篇)
uniapp 小程序 动态style class
Anti-shake throttling (continue to update later)
System delay tasks and scheduled tasks
再见Attention:建模用户长期兴趣的新范式
暴力破解美团最新JVM面试题:无限执行
2.5 - 死锁
坚持自主创新 线控底盘领军企业英创汇智获数亿元B+轮融资