/*
@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的更多相关文章

  1. [LeetCode] Climbing Stairs 爬梯子问题

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  2. [LintCode] Climbing Stairs 爬梯子问题

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  3. Leetcode: climbing stairs

    July 28, 2015 Problem statement: You are climbing a stair case. It takes n steps to reach to the top ...

  4. LintCode Climbing Stairs

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  5. 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 ...

  6. Climbing Stairs

    Climbing Stairs https://leetcode.com/problems/climbing-stairs/ You are climbing a stair case. It tak ...

  7. 3月3日(6) Climbing Stairs

    原题 Climbing Stairs 求斐波那契数列的第N项,开始想用通项公式求解,其实一个O(n)就搞定了. class Solution { public: int climbStairs(int ...

  8. 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 ...

  9. leetCode 70.Climbing Stairs (爬楼梯) 解题思路和方法

    Climbing Stairs  You are climbing a stair case. It takes n steps to reach to the top. Each time you ...

  10. 【LeetCode练习题】Climbing Stairs

    Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top. Each time you c ...

随机推荐

  1. linux 压缩zip包

    压缩: zip -r  名称.zip 被压缩文件 解压: unzip 名称.zip

  2. ReactiveSwift框架

    最近项目不多,所以就研究了一下RxSwift和RAS,RAC以前项目中用过了,在这里我就先简单的介绍一下什么是RAS.总述:在RAC 5.0这个版本,有了很大的改动,API已经重新命名.在和Swift ...

  3. (八)javaScript对象简介

            脚本对象(JavaScript对象) <script type="text/javascript"> var time=new Date(); time ...

  4. Strtus2 S2-045漏洞

    S2-045漏洞已经爆发几天了,但还很多网址都存在此漏洞,很多金融类网站也收到了保护费通知...唉,收保护费少,报警无效!只能酌情处理了!做黑产的,还是少做为秒,常在河边站哪有不湿鞋,劝各位早日金盆洗 ...

  5. C++ 容器对象vector和list 的使用

    在<<c++ primer>>第四版Exercise Section 9.3.4 的Exercise 9.20 是这样的一道题目:编写程序判断一个vector<int&g ...

  6. fprintf&prinft&sprintf

    1: fprintf()#include <stdio.h> int fprintf( FILE *stream, const char *format, ... );fprintf()函 ...

  7. javascript 随机显示指定内容

    今天碰到一个需求,一个页面显示赞助厂商的信息,但是厂商要求排序要随机排,因为是个静态页面不是读取数据库的,所以打算用js来控制 var arr = new Array('张三', '李四', '王五' ...

  8. Web 页面测试总结—控件类

    web端页面测试,最常见的是基本控件的测试,只有了解常见的控件和其测试方法,才能掌握测试要点,避免漏测情况发生.根据日常工作总结,将控件和常见逻辑集合在一起,总结了几个控件类测试查场景如下. 导航条 ...

  9. Spring Data操作Redis详解

    Spring Data操作Redis详解 Redis是一种NOSQL数据库,Key-Value形式对数据进行存储,其中数据可以以内存形式存在,也可以持久化到文件系统.Spring data对Redis ...

  10. Webpack多入口文件、热更新等体验

    Webpack现今流行的前端打包工具,今儿本人也来分享下自己学习体验. 一.html-webpack-plugin 实现html模板文件的解析与生成 在plugins加入HtmlWebpackPlug ...