LeetCode - 70. Climbing Stairs(0ms)
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?
Note: Given n will be a positive integer.
Example 1:
Input: 2
Output: 2
Explanation: There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
Example 2:
Input: 3
Output: 3
Explanation: There are three ways to climb to the top.
1. 1 step + 1 step + 1 step
2. 1 step + 2 steps
3. 2 steps + 1 step
class Solution {
public:
int climbStairs(int n) {
if(n == )
return ; int res[n + ];
res[] = ;
res[] = ;
for(int i = ; i <= n; i++)
res[i] = res[i - ] + res[i - ];
return res[n];
}
};
LeetCode - 70. Climbing Stairs(0ms)的更多相关文章
- 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 解 ...
- 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 爬楼梯问题
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 爬楼梯
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 ...
- LeetCode 70 Climbing Stairs(爬楼梯)(动态规划)(*)
翻译 你正在爬一个楼梯. 它须要n步才干究竟顶部. 每次你能够爬1步或者2两步. 那么你有多少种不同的方法爬到顶部呢? 原文 You are climbing a stair case. It tak ...
- Java [Leetcode 70]Climbing Stairs
题目描述: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either ...
- [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 ...
随机推荐
- JavaScript:改变 HTML 内容
使用Javascript来处理HTML元素的内容是非常强大的功能. <!DOCTYPE html><html><head><meta http-equiv=& ...
- py faster rcnn+ 1080Ti+cudnn5.0
看了py-faster-rcnn上的issue,原来大家都遇到各种问题. 我要好好琢磨一下,看看到底怎么样才能更好地把GPU卡发挥出来.最近真是和GPU卡较上劲了. 上午解决了g++的问题不是. 然后 ...
- FFMPEG系列一:Mac下FFMPEG编译安装配置及使用例子
系统环境:10.13以前系统版本,没有升级到macOS High Sierra.正常情况是直接输入brew install ffmpeg即可安装ffmpeg,但是该过程还是有一些坑需要填. 一.mac ...
- LinkedList---链表各种方法的实现
public class ListExer2 { public static void main(String[] args) { LinkList list = new LinkList(); li ...
- if switch for while
---恢复内容开始--- 一.if 说明:判断表达式,看结果执行语句体 public class IfDemo2 { public static void main(Strin ...
- Python函数中参数类型
在学习Python函数的时候,函数本身的定义和调用并不是很复杂,但是函数的参数类型和用法的确有些复杂.在此做一个小结,加深理解. Python参数的定义 负责给函数提供一些必要的数据或信息,以保证函数 ...
- rest_framework--序列化组件
#####序列化组件##### 一.什么是序列化 在python中一切皆对象,把对象从内存中变成可存储或传输的过程称之为序列化. 你写一个django项目肯定是有前后端交互的吧,虽然django也可以 ...
- aes 加密,解密
Javaaes加密: package com.sh.auth.util; import java.security.InvalidKeyException; import java.security. ...
- yarn的学习之2-容量调度器和预订系统
本文翻译自 http://hadoop.apache.org/docs/r2.8.0/hadoop-yarn/hadoop-yarn-site/CapacityScheduler.html 和http ...
- php接口数据加密、解密、验证签名【转】
<?php/** * 数据加密,解密,验证签名 * @edit http://www.lai18.com * @date 2015-07-08 **///header('Content-Type ...