当前位置:网站首页>February 13, 2022-2-climbing stairs
February 13, 2022-2-climbing stairs
2022-07-06 10:36:00 【Procedural ape does not lose hair 2】
Suppose you're climbing the stairs . need n You can reach the top of the building .
Every time you climb 1 or 2 A stair . How many different ways can you climb to the top of the building ?
Example 1:
Input :n = 2
Output :2
explain : There are two ways to climb to the top .
- 1 rank + 1 rank
- 2 rank
Example 2:
Input :n = 3
Output :3
explain : There are three ways to climb to the top .
- 1 rank + 1 rank + 1 rank
- 1 rank + 2 rank
- 2 rank + 1 rank
Tips :
1 <= n <= 45
java Code :
class Solution {
public int climbStairs(int n) {
if(n ==1 || n ==2) {
return n;
}
// Dynamic programming
int[] dp = new int[n+1];
dp[0] =1;
dp[1] = 1;
for(int i=2;i<=n;i++) {
dp[i] = dp[i-1] + dp[i-2];
}
return dp[n];
}
}
边栏推荐
- MySQL实战优化高手11 从数据的增删改开始讲起,回顾一下Buffer Pool在数据库里的地位
- 数据库中间件_Mycat总结
- The governor of New Jersey signed seven bills to improve gun safety
- Baidu Encyclopedia data crawling and content classification and recognition
- 16 medical registration system_ [order by appointment]
- MySQL实战优化高手05 生产经验:真实生产环境下的数据库机器配置如何规划?
- How to find the number of daffodils with simple and rough methods in C language
- 该不会还有人不懂用C语言写扫雷游戏吧
- Mysql33 multi version concurrency control
- Introduction tutorial of typescript (dark horse programmer of station B)
猜你喜欢
![[C language] deeply analyze the underlying principle of data storage](/img/d6/1c0cd38c75da0d0cc1df7f36938cfb.png)
[C language] deeply analyze the underlying principle of data storage

MySQL实战优化高手03 用一次数据更新流程,初步了解InnoDB存储引擎的架构设计

Mysql30 transaction Basics

Moteur de stockage mysql23

Unicode decodeerror: 'UTF-8' codec can't decode byte 0xd0 in position 0 successfully resolved
![[Julia] exit notes - Serial](/img/d0/87f0d57ff910a666fbb67c0ae8a838.jpg)
[Julia] exit notes - Serial

Mysql27 index optimization and query optimization

MySQL Real Time Optimization Master 04 discute de ce qu'est binlog en mettant à jour le processus d'exécution des déclarations dans le moteur de stockage InnoDB.

A necessary soft skill for Software Test Engineers: structured thinking

Jar runs with error no main manifest attribute
随机推荐
Download and installation of QT Creator
[C language] deeply analyze the underlying principle of data storage
Transactions have four characteristics?
MySQL实战优化高手09 生产经验:如何为生产环境中的数据库部署监控系统?
MySQL Real Time Optimization Master 04 discute de ce qu'est binlog en mettant à jour le processus d'exécution des déclarations dans le moteur de stockage InnoDB.
Solution to the problem of cross domain inaccessibility of Chrome browser
Time complexity (see which sentence is executed the most times)
First blog
软件测试工程师发展规划路线
MySQL36-数据库备份与恢复
Emotional classification of 1.6 million comments on LSTM based on pytoch
MySQL实战优化高手04 借着更新语句在InnoDB存储引擎中的执行流程,聊聊binlog是什么?
Typescript入门教程(B站黑马程序员)
Mysql27 - Optimisation des index et des requêtes
Vscode common instructions
16 medical registration system_ [order by appointment]
好博客好资料记录链接
Mysql35 master slave replication
【C语言】深度剖析数据存储的底层原理
Global and Chinese market of thermal mixers 2022-2028: Research Report on technology, participants, trends, market size and share