70. Climbing Stairs Add to List
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?
Subscribe to see which companies asked this question
///////////233333333一看题有点动态规划和组合的概念
///////////斐波那契数列
class Solution {
public:
int climbStairs(int n) {
if(n<=)
return ;
int p[n];
p[]=;
p[]=;
p[]=;
for(int i=;i<=n;i++)
p[i]=p[i-]+p[i-];
return p[n];
}
};
70. Climbing Stairs Add to List的更多相关文章
- 42. leetcode 70. Climbing Stairs
70. Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top. Each time y ...
- Leetcode#70. Climbing Stairs(爬楼梯)
题目描述 假设你正在爬楼梯.需要 n 阶你才能到达楼顶. 每次你可以爬 1 或 2 个台阶.你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数. 示例 1: 输入: 2 输出: 2 解 ...
- 377. Combination Sum IV 70. Climbing Stairs
back function (return number) remember the structure class Solution { int res = 0; //List<List< ...
- LN : leetcode 70 Climbing Stairs
lc 70 Climbing Stairs 70 Climbing Stairs You are climbing a stair case. It takes n steps to reach to ...
- Leetcode之70. Climbing Stairs Easy
Leetcode 70 Climbing Stairs Easy https://leetcode.com/problems/climbing-stairs/ You are climbing a s ...
- 刷题70. Climbing Stairs
一.题目说明 题目70. Climbing Stairs,爬台阶(楼梯),一次可以爬1.2个台阶,n层的台阶有几种爬法.难度是Easy! 二.我的解答 类似的题目做过,问题就变得非常简单.首先用递归方 ...
- LeetCode练题——70. Climbing Stairs
1.题目 70. Climbing Stairs——Easy You are climbing a stair case. It takes n steps to reach to the top. ...
- [LeetCode] 70. Climbing Stairs 爬楼梯问题
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- leetCode 70.Climbing Stairs (爬楼梯) 解题思路和方法
Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top. Each time you ...
随机推荐
- Harbor私有仓库搭建
1.安装docker yum install -y dockersystemctl start dockersystemctl enable docker 2.安装docker-compose 1.下 ...
- iOS imageNamed VS imageWithContentsOfFile
今天 又学习了 一个 提高应用交互效率 降低内存的 小知识 结论: (1)mageNamed加载图片,并且把image缓存到内存里面, (2)imageWithContentsOfFile是只显示图片 ...
- $SVN代码版本管理工具的使用
SVN是一种代码版本管理工具,具有可视化的操作界面,使用简便,和git的功能类似.下面总结一下SVN的基本用法: 1.安装SVN软件,和安装一般的软件的步骤差不多,这里使用的版本是TortoiseSV ...
- arcgis for flex map遮罩
效果1:map的遮罩(对整个map进行遮罩) 效果2:对某个图层进行遮罩
- 每日练习level-7
1.有序列表.无序列表.自定义列表如何使用?写个简单的例子.三者在语义上有什么区别?使用场景是什么? 能否嵌套? 有序列表是一列使用数字进行标记的项目,它使用<li>包含于<ol&g ...
- SQL查询语句的执行顺序
- Luogu-2495 [SDOI2011]消耗战
虚树第一题 对于每次询问的点建立一棵虚树,然后在树上DP,一个点的答案就是这个点的父边切断的代价与所有儿子切断的代价去最小值,当然如果这个节点是资源点则必须切父边 注意在虚树上一条边的代价应该是中间所 ...
- 用TinyXml做XML解析示例 TinyXml查找唯一节点及修改节点操作
// 读者对象:对TinyXml有一定了解的人.本文是对TinyXml工具的一些知识点的理解. // 1 TinyXml中对TiXmlNode进行了分类,是用一个枚举进行描述的. // enum No ...
- Java中interface是否继承Object类
首先我们从C++说起, c++可以多继承.也就是一个类型 --- class,可以继承自2个以上的父类型.多继承导致一个问题,很多人知道.例如,如果类型B,类型C均继承自类型A.然后类型D继承自类型B ...
- numpy array或matrix的交换两行
A[j,:] = A[maxindex,:] # 注意这样是一个很低级的错误!这样只是赋值 我们很容易想起python中的两个值交换一句搞定不用引入中间变量 a, b = b, a 但在numpy的a ...