#leetcode#70.Climbing Stairs
来源:互联网 发布:新品牌网络推广方案 编辑:程序博客网 时间:2024/04/28 10:25
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?
斐波那契数列,计算迭代f(n)=f(n-1)+f(n-2)
class Solution {public: int climbStairs(int n) { int a[n]={0}; if(n==0) return 0; if(n==1) return 1; if(n==2) return 2; a[0]=1; a[1]=2; int i; for(i=2;i<n;i++) { a[i]=a[i-1]+a[i-2]; } return a[n-1]; }};
0 0
- [LeetCode]70.Climbing Stairs
- LeetCode --- 70. Climbing Stairs
- [Leetcode] 70. Climbing Stairs
- [leetcode] 70.Climbing Stairs
- [leetCode]70. Climbing Stairs
- 70. Climbing Stairs LeetCode
- [LeetCode]70. Climbing Stairs
- 【LeetCode】70. Climbing Stairs
- leetcode 70. Climbing Stairs
- leetcode 70. Climbing Stairs
- LeetCode *** 70. Climbing Stairs
- 【LeetCode】70. Climbing Stairs
- LeetCode 70. Climbing Stairs
- leetcode 70. Climbing Stairs
- [LeetCode]70. Climbing Stairs
- 【LeetCode】70. Climbing Stairs
- LeetCode 70. Climbing Stairs
- #leetcode#70.Climbing Stairs
- 电脑常用快捷键
- 【UNET自学日志】Part11 玩家复活
- eclipse中pydev开发报错:Project interpreter not specified
- TCP/IP协议族中tcp与udp的区别
- C++使用matlab卷积神经网络库MatConvNet来进行手写数字识别
- #leetcode#70.Climbing Stairs
- 当用Thread的子类构造创建多线程时,并同时传入Runnable覆盖run方法时,此时执行的run方法是
- cmake使用
- 操作XML
- uCOS任务堆栈的深入分析
- Android常用包相关说明
- Handler内存泄露的分析与解决
- 位运算
- 编程之美区间重合判断