/*
@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. JavaScript中冒泡排序

    在我大学的时候,就已经接触到过很多的排序方式,只是那时候听得还很懵懂,大概知道这么个东西,也对冒泡排序有点印象,但真要我写,我是写不出来的.最近,在回顾js基础的时候,又接触到了冒泡排序.于是,就把冒 ...

  2. 网络信息安全攻防学习平台 上传,解密通关writeup

    上传关 [1]查看源代码,发现JS代码.提交时onclick进行过验证.ctrl+shift+i 打开开发者工具,将conclick修改为 return True,即可以上传上传php文件,拿到KEY ...

  3. CentOS 7安装配置FTP服务器

    CentOS 7下FTP服务器的安装配置. 假设我们有以下要求 路径 权限 备注 /ftp/open 公司所有人员包括来宾均可以访问 只读 /ftp/private 仅允许Alice.Jack.Tom ...

  4. TuSDK 简易使用方法 持有图片对象方式

    TuSDK 为涂图照相应用的SDK,打包后文件大小约为5M,缺点为包比较大,且图片清晰度较差一些,优点为直接可以引用滤镜贴纸,方便易用.   使用方法如下:    1.AppDelegate.m 中加 ...

  5. Weexpack 使用教程

    简介 weexpack 是 weex 新一代的工程开发套件,是基于weex快速搭建应用原型的利器.它能够帮助开发者通过命令行创建weex工程,添加相应平台的weex app模版,并基于模版从本地.Gi ...

  6. Android Material Design 系列之 SnackBar详解

    SnackBar是google Material Design提供的一种轻量级反馈组件.支持从布局的底部显示一个简洁的提示信息,支持手动滑动取消操作,同时在同一个时间内只能显示一个SnackBar. ...

  7. mysql编程--创建函数出错的解决方案

    本文章转载自:http://www.jb51.net/article/71100.htm 在使用MySQL数据库时,有时会遇到MySQL函数不能创建的情况.下面就教您一个解决MySQL函数不能创建问题 ...

  8. 设置border属性变化不同形状:三角形、圆形、弧形 2017-03-20

    一.通过设置边框----正方形.三角形 <style> .c{ height: 0px; width: 0px; border-top: 50px solid red; border-ri ...

  9. python3.6 简单爬虫

    # coding='UTF-8' from bs4 import BeautifulSoup # 引入beautifulsoup 解析html事半功倍 import re import urllib ...

  10. 串的模式匹配和KMP算法

    在对字符串的操作中,我们经常要用到子串的查找功能,我们称子串为模式串,模式串在主串中的查找过程我们成为模式匹配,KMP算法就是一个高效的模式匹配算法.KMP算法是蛮力算法的一种改进,下面我们先来介绍蛮 ...