70. Climbing Stairs
2016-06-08 10:54
330 查看
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?
DP方法:
step
= step[n-1]+step[n-2];
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
DP方法:
step
= step[n-1]+step[n-2];
class Solution { public: int climbStairs(int n) { vector<int> step(n,0); step[0] = 1; step[1] = 2; for(int i = 2;i<n;i++){ step[i] = step[i-1]+step[i-2]; } return step[n-1]; } };
相关文章推荐
- Vmware Failed to login into NFC server Datastore error
- 用genymotion安装应用出现INSTALL_FAILED_CPU_ABI_INCOMPATIBLE的错误
- 《人工智能的明天,中国去哪儿》---汤晓鸥
- COPY, RETAIN, ASSIGN , READONLY , READWRITE,STRONG,WEAK,NONATOMIC整理
- ping: unknown host www.baidu.com
- 51nod 1305 Pairwise Sum and Divide
- Autofac IContainer 测试
- CodeForces 667A Pouring Rain
- 游戏中的AI算法总结与改进
- ERROR [main] zookeeper.RecoverableZooKeeper: ZooKeeper exists failed after 4 attempts
- 判断Set中课程是否存在,Contains方法
- LeetCode 11 Container With Most Water
- TurboMail邮件系统邮件归档模块介绍
- hdu1532-Drainage Ditches
- Avoid on a Thank-You Email
- Contains Duplicate III
- Contains Duplicate II
- CodeForces 675B Restoring Painting
- 219.[Leetcode]Contains Duplicate II
- Airbnb