当前位置:网站首页>NC68 跳台阶
NC68 跳台阶
2022-07-25 18:13:00 【syc596】
NC68 跳台阶
JZ69 跳台阶
// //递归
// public class Solution {
// public int jumpFloor(int target) {
// if(target==0){
// return 1;
// }
// if(target==1){
// return 1;
// }
// if(target==2){
// return 2;
// }
// return jumpFloor(target-1)+jumpFloor(target-2);
// }
// }
// //迭代1
// public class Solution {
// public int jumpFloor(int target) {
// if(target==0){
// return 1;
// }
// if(target==1){
// return 1;
// }
// if(target==2){
// return 2;
// }
// int first=1;
// int second=2;
// int third=0;
// while(target>2){
// third=first+second;
// first=second;
// second=third;
// target--;
// }
// return third;
// }
// }
// //迭代2
// public class Solution {
// public int jumpFloor(int target) {
// if(target==0){
// return 1;
// }
// if(target==1){
// return 1;
// }
// if(target==2){
// return 2;
// }
// int first=1;
// int second=2;
// int third=0;
// for(int i=3;i<=target;i++){
// third=first+second;
// first=second;
// second=third;
// }
// return third;
// }
// }
//11
//动规dp
public class Solution {
public int jumpFloor(int target) {
// if(target==0){
// return 1;
// }
// if(target==1){
// return 1;
// }
// if(target==2){
// return 2;
// }
int[] dp=new int[target+1];//target+1防止数组越界
dp[0]=1;
dp[1]=1;
for(int i=2;i<=target;i++){
dp[i]=dp[i-1]+dp[i-2];
}
return dp[target];
}
}边栏推荐
- ORB_ Slam3 recurrence - Part I
- Ch582 ble 5.0 uses Le coded broadcast and connection
- Could not stop Cortex-M device! Please check the JTAG cable solution
- Basic knowledge of software testing (mind mapping)
- C# Linq 去重&去重求和
- Joseph Ring problem
- Number two 2010 real test site
- Introduction to cloud XR and development opportunities of cloud XR in 5g Era
- NPDP多少分通过?如何高分通过?
- How to choose digital twin visualization platform
猜你喜欢

乐观锁解析

云VR:虚拟现实专业化的下一步
![Why is the index in [mysql] database implemented by b+ tree? Is hash table / red black tree /b tree feasible?](/img/1f/a2d50ec6bc97d52c1e7566a42e564b.png)
Why is the index in [mysql] database implemented by b+ tree? Is hash table / red black tree /b tree feasible?

What is the relationship between cloud fluidization and cloud desktop

Express of nodejs simple example program

"Jargon" | what kind of experience is it to efficiently deliver games with Devops?

Why the future of digitalization depends on 3D real-time rendering

Related operations of figure

Stm8s003f3 internal flash debugging

Connect to MySQL using sqldeveloper
随机推荐
OV7725 yuv 640* [email protected] Profile
SLA 、SLO & SLI
CVE-2022-33891 Apache spark shell 命令注入漏洞复现
Leetcode 101. symmetric binary tree & 100. same tree & 572. Subtree of another tree
对角化、A的幂
Connect to MySQL using sqldeveloper
Stm8s003f3 internal flash debugging
SDLC 软件开发生命周期及模型
专访即构科技李凯:音视频的有趣、行业前沿一直吸引着我
大话DevOps监控,团队如何选择监控工具?
ORB_ Slam3 recurrence - Part I
srec_cat 常用参数的使用
Unity 贝塞尔曲线的创建
“Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0”问题解决
MATLAB中join函数使用
超全Mavan标签详解
List conversion problem
What is the relationship between cloud fluidization and cloud desktop
「行话」| 用DevOps高效交付游戏,是种什么体验?
mysql的小数number类型select之后丢失了前面的0