[Leetcode 70, easy] Climbing Stairs
来源:互联网 发布:vb用的是什么语言 编辑:程序博客网 时间:2024/05/16 11:42
Problem:
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?
Analysis:
Solutions:
C++:
int climbStairs(int n) { if(n == 0) return n; vector<int> different_ways; different_ways.push_back(1); for(int i = 1; i < n; ++i) { if(i == 1) different_ways.push_back(2); else different_ways.push_back(different_ways[i - 1] + different_ways[i - 2]); } return different_ways[n - 1]; }Java:
Python:
0 0
- [Leetcode 70, easy] Climbing Stairs
- 【LeetCode】(70)Climbing Stairs (Easy)
- Leetcode #70 - Climbing Stairs - Easy
- 【Leetcode-Easy-70】Climbing Stairs
- LeetCode-70-Climbing Stairs(动态规划)-Easy
- Leetcode OJ 70 Climbing Stairs [Easy]
- [leetcode][easy]70. Climbing Stairs
- (Leetcode)70.Climbing Stairs(easy)
- LeetCode 70. Climbing Stairs (Easy)
- leetcode 70 Climbing Stairs(难易度:Easy)
- <LeetCode><Easy> 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
- 400错误
- 后台线程与UI线程的交互
- Android内存溢出解决办法BitmapFactory decoding大文件
- 创建渐变背景图片
- vc++调用exe时,如何获取exe的输出信息(输出显示在IDE的输出中)
- [Leetcode 70, easy] Climbing Stairs
- Java截图
- 个人归纳Log4j概念
- java中List转数组,数组转List
- 第二大的数
- Generic Programming and the STL笔记5--Iterator Classes
- 应用程序的代码混淆(打包)
- hdu 5207 Greatest Greatest Common Divisor(数论)
- android语音识别之科大讯飞语音API的使用