111_climbing-stairs
/*
@Copyright:LintCode
@Author: Monster__li
@Problem: http://www.lintcode.com/problem/climbing-stairs
@Language: Java
@Datetime: 17-03-05 05:12
*/
public class Solution {
/**
* @param n: An integer
* @return: An integer
*/
public int climbStairs(int n) {
//int sumways=0;
//int step_index,i;
//int steps[]={1,2};
int step[]=new int[1024];
step[0]=1;step[1]=1;
//step[2]=2;
for(int step_index=2;step_index<=n;step_index++)
{
step[step_index]=step[step_index-1]+step[step_index-2];
}
/*
class climbtest{
int climb(int steps)
{
if(steps<n)
return climb(++steps);
else return sumways;
}
}
*/
/*
if(n>1)
return climbStairs(n);
else return sumways;
*/
return step[n];
}
}
111_climbing-stairs的更多相关文章
- [LeetCode] Climbing Stairs 爬梯子问题
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- [LintCode] Climbing Stairs 爬梯子问题
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- Leetcode: climbing stairs
July 28, 2015 Problem statement: You are climbing a stair case. It takes n steps to reach to the top ...
- LintCode Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- 54. Search a 2D Matrix && Climbing Stairs (Easy)
Search a 2D Matrix Write an efficient algorithm that searches for a value in an m x n matrix. This m ...
- Climbing Stairs
Climbing Stairs https://leetcode.com/problems/climbing-stairs/ You are climbing a stair case. It tak ...
- 3月3日(6) Climbing Stairs
原题 Climbing Stairs 求斐波那契数列的第N项,开始想用通项公式求解,其实一个O(n)就搞定了. class Solution { public: int climbStairs(int ...
- Cllimbing Stairs [LeetCode 70]
1- 问题描述 You are climbing a stair case. It takes n steps to reach to the top. Each time you can eithe ...
- 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练习题】Climbing Stairs
Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top. Each time you c ...
随机推荐
- Spring+CXF的WebServices简单示例
本文就最简单的WebServices示例来演示Spring和CXF的整合. 使用Maven创建webapp项目,pom如下 <properties> <cxf.version> ...
- 2015年ACM-ICPC亚洲区域赛合肥站网络预选赛H题——The Next (位运算)
Let L denote the number of 1s in integer D's binary representation. Given two integers S1 and S2, we ...
- 一个好用的几乎没有Callback的Android异步库
android-async-task 这是一个Android平台处理复杂异步任务的库 (https://github.com/gplibs/android-async-task) 1. 安装方法 gr ...
- 单源最短路径问题之dijkstra算法
欢迎探讨,如有错误敬请指正 如需转载,请注明出处 http://www.cnblogs.com/nullzx/ 1. 算法的原理 以源点开始,以源点相连的顶点作为向外延伸的顶点,在所有这些向外延伸的顶 ...
- WPF 动态生成DataGrid及动态绑定解决方案
一.场景 有过WPF项目经验的朋友可能都知道,如果一个DataGrid要绑定静态的数据是非常的简单的(所谓静态是指绑定的数据源的类型是静态的),如下图所示,想要显示产品数据,只需绑定到一个产品列表即可 ...
- 双系统删除Ubuntu后出现grub界面而无法正常启动Windows系统的解决方法
第一次安装双系统的时候由于不怎么会弄,设置了ubuntu引导windows,这种方法是非常不推荐的,因为当ubuntu出现问题或者是当你不再使用ubuntu的时候,删除ubuntu就会成为一个很麻烦的 ...
- java学习笔记 --- java基础语法
一.java标识符,关键字,保留字 1.标识符 用来增强程序阅读性自定义的名字.类名,变量名,方法名等都可以被称为标识符 标识符的组成: 1.由数字(0-9),字母(a-z,A-Z),下划线(_),美 ...
- 【Unity游戏开发】浅谈 NGUI 中的 UIRoot、UIPanel、UICamera 组件
简介 马三最近换到了一家新的公司撸码,新的公司 UI 部分采用的是 NGUI 插件,而之前的公司用的一直是 Unity 自带的 UGUI,因此马三利用业余时间学习了一下 NGUI 插件的使用,并把知识 ...
- linux命令之查看字符集
lucifer@abc:~$ locale -a 查看本地字符集lucifer@abc:~$ locale -m 查看所有支持的字符集将文件从gb2312转为utf8iconv -f gb2312 - ...
- C#研究OpenXML之路(3-OpenXMLSDKToolV25.msi)
一.OpenXMLSDKToolV25.msi 看了几天的OpenXml,感觉如果完全手写代码,将会是一件非常苦逼的事情,即要分析对应xlsx文件层次结构,以及包含的xml文件的xml标签结构,还要关 ...