LeetCode之旅(16)
来源:互联网 发布:后花园软件下载安装 编辑:程序博客网 时间:2024/06/05 00:56
Climbing Stairs
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) { int *res = new int[n+1]; res[0] = res[1] = 1; for (int i=2; i<=n; i++) res[i] = res[i-1] + res[i-2]; return res[n]; }};
0 0
- LeetCode之旅(16)
- LeetCode之旅(16)-Climbing Stairs
- LeetCode之旅(2)
- LeetCode之旅(3)
- LeetCode之旅(4)
- LeetCode之旅(5)
- LeetCode之旅(6)
- LeetCode之旅(7)
- LeetCode之旅(8)
- LeetCode之旅(9)
- LeetCode之旅(10)
- LeetCode之旅(12)
- LeetCode之旅(13)
- LeetCode之旅(14)
- LeetCode之旅(15)
- LeetCode之旅(17)
- LeetCode之旅(18)
- LeetCode之旅(19)
- gumptious linux驱动移植的重要数据结构(一)
- Oracle EBS RCV模块日志收集方法
- #include 相互引用的问题
- 【linux】df命令
- 使用Pspice进行电路仿真
- LeetCode之旅(16)
- 如梦令-无眠码农
- OpenCV基础篇之图片叠加
- vim设置tabstop,自动缩进没变
- looper and handler
- 给老婆发奖
- AsyncTask学习
- 出现( linker command failed with exit code 1)错误总结
- 笔试面试那件小事(数据库SQL查询)