LeetCode - 70. Climbing Stairs(0ms)
2024-09-26 21:39:35
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Note: Given n will be a positive integer.
Example 1:
Input: 2
Output: 2
Explanation: There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
Example 2:
Input: 3
Output: 3
Explanation: There are three ways to climb to the top.
1. 1 step + 1 step + 1 step
2. 1 step + 2 steps
3. 2 steps + 1 step
class Solution {
public:
int climbStairs(int n) {
if(n == )
return ; int res[n + ];
res[] = ;
res[] = ;
for(int i = ; i <= n; i++)
res[i] = res[i - ] + res[i - ];
return res[n];
}
};
最新文章
- Easymake
- PHP实现执行定时任务的几种思路详解
- bootstrap datetimepicker 中只显示年或者只显示月份
- 调试技巧--Windows端口号是否被占用
- windows上修改路由表
- 容易网CEO陈从容:用分享成就生活之美
- APUE学习总结
- android获得屏幕高度和宽度(display中getSize(Point)方法使用)
- 设置TrackMouseEvent捕获WM_MOUSEHOVER和WM_MOUSELEAVE消息
- NYOJ15-括号匹配(二)-区间DP
- spring源码系列(一)sring源码编译 spring源码下载 spring源码阅读
- md5加密utils
- MUD 多人地下城
- PHP创建socket服务
- RabbitMQ 安装与使用
- 南理第八届校赛同步赛-C count_prime//容斥原理
- 【组合&;取补集】数三角形 @CQOI2014/BZOJ3505/upcexam3843
- PCA降维实验代码
- Linux rhel7 下MySQL5.7.18详细安装文档
- Java 默认事务级别read committed对binlog_format的需求