70.爬楼梯
来源:互联网 发布:python学习手册 mobi 编辑:程序博客网 时间:2024/05/16 07:36
Climbing Stairs
问题描述:
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.
测试代码(c++):
class Solution {public: int climbStairs(int n) { if(n<=2) return n; vector<int> dp(n,0); dp[0] = 1; dp[1] = 2; for(int i=2;i<n;i++) { dp[i] = dp[i-2]+dp[i-1]; } return dp[n-1]; }};
性能:
阅读全文
0 0
- 70.爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- 爬楼梯
- org.json.JSONException: Value java.net.UnknownHostException of type java.lang.String cannot be conv
- HDU
- 【javascript】您好, 您要的ECMAScript6速记套餐到了 (一)
- D29 RDD高级算子
- Java 内部类的一些总结
- 70.爬楼梯
- Mips TLB miss实现in Linux
- Linux shell 的 test 命令用法详解
- jsp后一个窗口传值给前一个窗口,子父窗口之间的传值
- Bell数
- 百度富文本编辑器Ueditor上传图片时标签中添加宽高
- uva 1347 动态规划DAG lrj-P269
- 闲聊Linux内存管理(1)
- leetcode 300. Longest Increasing Subsequence