Submission Details
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?
int climbStairs(int n) { int step[n]; int i = 0; if(n <= 2) return n; step[0] = 1; step[1] = 2; for(i = 2; i < n; i++) { step[i] = step[i - 2] + step[i - 1]; } return step[i - 1];}- 用斐波那契的递归处理,到44时就会消耗过大而失败;
- 递归在程序最后时,都是可以用for来代替的
- 在for里面定义的变量,对于for外面也是不可见的!
Submission Details的更多相关文章
- LeetCode——Submission Details
Description: Given a string of numbers and operators, return all possible results from computing all ...
- Submission Details [leetcode] 算法的改进
最先看到这一题,直觉的解法就是len从1到s1.size()-1,递归调用比較s1和s2长度为len的子串是否相等.以及剩余部分是否相等. 将s1分成s1[len + rest],分别比較s2[len ...
- leetcode Submission Details
代码: #include<iostream> #include<vector> using namespace std; struct ListNode { int val; ...
- 【leetcode】Submission Details
Given two sentences words1, words2 (each represented as an array of strings), and a list of similar ...
- [sqoop1.99.6] 基于1.99.6版本的一个小例子
1.创建mysql数据库.表.以及测试数据mysql> desc test;+-------+-------------+------+-----+---------+------------- ...
- [sqoop1.99.7] sqoop实例——数据ETL
一.创建一个mysql的link MySQL链接使用的是JDBC,必须有对应的驱动文件jar,还得有对应的访问权限,请确保能在server端访问MySQL.确保mysql的jar包已经导入到${SQO ...
- [LeetCode OJ] Max Points on a Line
Max Points on a Line Submission Details 27 / 27 test cases passed. Status: Accepted Runtime: 472 ms ...
- Sqoop安装与应用过程
1. 参考说明 参考文档: http://sqoop.apache.org/ http://sqoop.apache.org/docs/1.99.7/admin/Installation.html ...
- sqoop2的使用测试
查看现有link sqoop:000> show link+-----------+------------------------+---------+| Name | Co ...
随机推荐
- Delphi Length函数
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- codeforces 335A Banana(贪心)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Banana Piegirl is buying stickers for ...
- php sscanf() 函数使用
定义和用法 sscanf() 函数根据指定的格式解析来自一个字符串的输入. 如果只向该函数传递两个参数,数据将以数组的形式返回.否则,如果传递了额外的参数,那么被解析的数据会存储在这些参数中.如果区分 ...
- [原]用C#模拟实现扑克牌发牌、排序程序。
(1)52张扑克牌,四种花色(红桃.黑桃.方块和梅花),随机发牌给四个人. (2)最后将四个人的扑克牌包括花色打印在控制台上. 其中: 花色和点数用枚举类型实现 每张扑克牌用结构实 ...
- 我是菜鸟,我怕谁--hdu2520
我是菜鸟,我怕谁 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- Super Jumping! Jumping! Jumping!(hdu 1087 LIS变形)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- BC 65 game
主持人一直某个数字在1到n范围,假设甲乙已经知道,甲先猜乙后,都采用最优策略,主持人说偏大还是偏小,不断缩小范围,问最后乙能会获胜的X的取值的个数. 如果n为奇数,那么仅当x=n/2乙必然获胜,若为奇 ...
- Keil中Memory Model和Code Rom Size说明
C51中定义变量时如果省略存储器类型,Keil C51编译系统则会按编译模式SMALL.COMPACT和LARGE所规定的默认存储器类型去指定变量的存储区域,无论什么存储模式都可以声明变量在任何的80 ...
- Spring Task Scheduler - No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined
1. Overview In this article, we are discussing the Springorg.springframework.beans.factory.NoSuchBea ...
- Android framework浅析[转]
Android系统从底向上一共分了4层,每一层都把底层实现封装,并暴露调用接口给上一层. 1. Linux内核(Linux Kernel) 1)Android运行在linux kernel 2.6之上 ...