[Leetcode] Climbing Stairs
来源:互联网 发布:欧洲30年战争知乎 编辑:程序博客网 时间:2024/06/05 17:07
ou 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?
public class Solution { public int climbStairs(int n) { if(n==1) return 1; if(n==2) return 2; int sum1=1; int sum2=2; int sum3=3; int i=3; while(i<=n) { sum3=sum1+sum2; sum1=sum2; sum2=sum3; i++; } return sum3; }}
0 0
- LeetCode: Climbing Stairs
- LeetCode: Climbing Stairs
- [LeetCode]Climbing Stairs
- LeetCode Climbing Stairs
- [Leetcode] Climbing Stairs
- Leetcode: Climbing stairs
- LeetCode Climbing Stairs
- [LeetCode] Climbing Stairs
- leetcode 107: Climbing Stairs
- [LeetCode] Climbing Stairs
- [LeetCode]Climbing Stairs
- [leetcode]Climbing Stairs
- LeetCode-Climbing Stairs
- [leetcode] Climbing Stairs
- LeetCode - Climbing Stairs
- LeetCode:Climbing Stairs
- Leetcode Climbing Stairs
- LeetCode | Climbing Stairs
- 每日一省之—基于双数组和二分查找法实现符号表(或者字典)
- HDU Problem 1711 Number Sequence 【KMP】
- 【原创】东方耀reactnative 视频18之-Touchable组件
- 第三周 项目三-求集合并集
- c语言将小写字母转换为大写字母
- [Leetcode] Climbing Stairs
- UGUI内核大探究(九)Image与RawImage
- 面向对象的三个基本特征 和 五种设计原则
- Java中反射(Reflection)的应用
- 利用C++ Boost编写扩展Python模块
- 文章标题
- Dual Palindromes(USACO)
- codeforces 682 a 解题报告 Alyona and Numbers 数论基础
- [Leetcode] Best Time to Buy and Sell Stock