70. Climbing Stairs
2016-01-06 21:24
459 查看
题目:
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?
解题思路:
动态规划
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?
解题思路:
动态规划
class Solution { public: int climbStairs(int n) { if(n<=2)return n; vector<int> res(n+1,0); res[1]=1; res[2]=2; for(int i=3;i<=n;i++) res[i] = res[i-1]+res[i-2]; return res ; } };
相关文章推荐
- List的contains()方法(转)
- 解决: Fail to create empty document
- LoadRunner运行场景,错误---Error: Failed to send data by channels - post message failed.
- Sicily 1741. Jaunt around the Zhuhai Campus
- 新手安装cocoapods OSX EI captain
- canvas中paint画圆时strokewidth和radius的关系
- sencha touch编译报错:“bfailed to create task or type x-compass-compile Cause: The name is undefined”
- 算法杂货铺——分类算法之朴素贝叶斯分类(Naive Bayesian classification)
- 服务器最大连接数“server reached MaxClients setting,consider raising the Max Clients setting”
- std::pair
- _CGImageSourceContainsAnimatedGif、_CGImageSourceCopyProperties、_CADisplayLink、_kUTTypeGIF
- 使用线程 Monitor.Wait() 和 Monitor.Pulse()
- High Availability (HA) 和 Disaster Recovery (DR) 的区别
- baidu招聘
- leetcode第11题——**Container With Most Water
- 【bzoj4320】【ShangHai2006 Homework】【并查集+离线处理】
- 如何辨别磁盘阵列的性能
- extmail
- Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd'问题解决方法
- Handler sendMessage 与 obtainMessage (sendToTarget)比较